0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PurchasesHybridCommon/CommonFunctionality.swift:21: Fatal error: Purchases has not been configured. Please configure the SDK before calling this methodについて解決してみた。

Posted at

今回は以下のようなエラーに対処してみました。

flutterでのrestoreができなかったんです。
しかし、色々と検索してみたら初期化する前にrestoreを呼び出していたことが原因だったということでした。

PurchasesHybridCommon/CommonFunctionality.swift:21: 
Fatal error: Purchases has not been configured. 
Please configure the SDK before calling this method

これはflutterにおいてはmain関数で事前に初期化しておくことが必須なのです

import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:purchases_flutter/purchases_flutter.dart';

void main() async {
  // Flutterのバインディングを初期化
  WidgetsFlutterBinding.ensureInitialized();

  // Firebaseの初期化
  await Firebase.initializeApp();

  // RevenueCatの初期化
  await Purchases.setLogLevel(LogLevel.debug);
  await Purchases.configure(PurchasesConfiguration("api_key"));

  // アプリの起動
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'My App',
      home: HomeScreen(),
    );
  }
}

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?