Göktürk
Göktürk

Reputation: 67

Revenuecat Fix Prewarm Issue for Flutter

From the docs

In certain cases, iOS may prewarm your app - this essentially means your app will be launched silently in the background to improve app launch times for your users.

If you are not using RevenueCat's anonymous IDs as described above, and are instead providing your own app user ID on configuration, do not call configure in application:didFinishLaunchingWithOptions:. Instead, call the configure method in your root view controller's initialization method.

I am struggling to understand the implication of this for a flutter app. Is it alright if we initialize Purchases from the main method before runApp is executed or do we have to do it in the initialization method of the application.

So would it work if we do something like

Future<void> main() async {
   await Purchases.configure()
   runApp(MyApp(...)) 
}

Or do we have to do this in MyApp initializer like

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool isInitalized

  @override
  void initState() {
    Purchases.configure().then((_) => isInitalized = true);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    isInitalized ? return MaterialApp(...) : return CircularProgressIndicator();
  }
}

Looked up docs but no specific info about flutter

Upvotes: 0

Views: 33

Answers (0)

Related Questions