Flutter SDK syncPurchases method

  • 30 September 2022
  • 5 replies

Badge +1
  • New Member
  • 0 replies

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

Any updated on this?

Badge +4

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.

Userlevel 5
Badge +8

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:

Badge +4

@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).

Userlevel 5
Badge +8

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