Solved

Flutter - General guidance with PresentPaywall and addCustomerInfoUpdateListener

  • 9 April 2024
  • 2 replies
  • 28 views

Badge +3

Hello,

Just asking some quick clarification questions publicly in case they help others, these are specific for Flutter but I would assume that they’re applicable for other SDKs.

1. I am invoking:

PaywallResult paywallResult = await RevenueCatUI.presentPaywallIfNeeded("Premium", displayCloseButton: true);

I would assume that the only thing I can do to “react” to whatever the user did would be to switch on the enum - no other subscription details bar PaywallResult (notPresented, cancelled, error, purchased, restored) are returned?

2. Related but I also noticed that you can hook into subscription changes like this:

    Purchases.addCustomerInfoUpdateListener((customerInfo) async {

});

Would you do this in a centralised place (like where we are initialising the SDK), to listen for all subscription changes for a user and then “observe” these using a ChangeNotifier or similar?

icon

Best answer by sharif 11 April 2024, 19:46

View original

This post has been closed for comments

2 replies

Userlevel 5
Badge +9

Hi @Mark Walsh,

  1. Yes correct, PaywallResult is the main way to get info out of the paywall. It’s also common to call getCustomerInfo after the paywall result to see the current status of the customer’s subscription after any successful purchases.
  2. There are two ways you can do this. One way is to go the listener route and add a listener to react to changes. You can add the listener in a central place where you can notify various parts of your app of updates or you can add multiple listeners so you don’t have to manage distributing updates throughout your app. The other way to go is to simply call getCustomerInfo any time a user access paid content or takes an action, for example every time the user navigates to a paid part of your app. getCustomerInfo caches data and is designed to be called very frequently in your app.
Badge +3

Cheers - Great answer!