Reputation: 2791
I'm using RevenueCat on Flutter, where do I call:
Purchases.addPurchaserInfoUpdateListener((purchaserInfo) => {});
so that I can listen for updates to purchase status across my entire app? Thanks.
Upvotes: 1
Views: 1267
Reputation: 7660
You can Purchases.addPurchaserInfoUpdateListener((purchaserInfo) => {});
to the initState
of your app widget.
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
Purchases.addPurchaserInfoUpdateListener((purchaserInfo) => {
// do what you want with the purchase info
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: Constants.appName,
theme: ThemeConfig.lightTheme,
home: Splash(),
);
}
}
Upvotes: 2