Skip to main content
Question

Flutter SDK syncPurchases method

  • 30 September 2022
  • 5 replies
  • 182 views

Forum|alt.badge.img+3

I’m trying to use the syncPurchases method in the Flutter SDK before checking entitlements to determine free trial eligibility on Android.

This workaround was suggested by Cody in the thread here: 

 

However, despite the function returning a future, await Purchases.syncPurchases() doesn’t seem to actually await the purchases being synced. Looking at the Purchases package (see below), it doesn’t seem to await the method being invoked.

  ///  This method will send all the purchases to the RevenueCat backend.
  ///
  ///  **WARNING**: Call this when using your own implementation of in-app
  ///  purchases.
  ///
  ///  This method should be called anytime a sync is needed, like after a
  ///  successful purchase.
  static Future<void> syncPurchases() => _channel.invokeMethod('syncPurchases');

Is this a bug, or is it not possible to await the purchases being synced?

5 replies

Forum|alt.badge.img+3

Any updated on this?


Forum|alt.badge.img+5
  • Active Member
  • 11 replies
  • December 12, 2022

FYI in the unity SDK, this method doesn’t even have a callback method. The main use case for this method for us is to wait until we know purchases were synced, then check the entitlement. Not knowing when purchases were synced feels like a design flaw in the current implementation, but I’d love to be proven wrong here.


cody
RevenueCat Staff
Forum|alt.badge.img+8
  • RevenueCat Staff
  • 487 replies
  • January 12, 2023

Hey all,

I think a workaround here may be to set up a listener for CustomerInfo - after syncPurchases, if there is any change to CustomerInfo, the observer would be called: https://www.revenuecat.com/docs/customer-info#listening-for-customerinfo-updates


Forum|alt.badge.img+5
  • Active Member
  • 11 replies
  • January 12, 2023

@cody we are listening in to that method, but the issue is that we don’t know if there’s supposed to be a change or not to the subscription state. That’s why we’re calling sync purchases.

Not having a callback after a sync means that devs need to wait arbitrary periods after calling sync, need to handle uncertain states if that arbitrary waiting period is over but the sync isn’t, etc.

Syncpurchases is used in multiple cases, but for all of them it would simplify things a lot to know when that operation is completed. We can then know that the user is definitely not subscribed, instead of having to deal with uncertainty for an unknown amount of time (possibly forever if an error happened).


cody
RevenueCat Staff
Forum|alt.badge.img+8
  • RevenueCat Staff
  • 487 replies
  • January 17, 2023

Hey @Ululab, I totally understand, thanks for the great feedback here - I’ll share this with the SDK team!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings