adaptyteam / AdaptySDK-Flutter

SDK for growing mobile in-app purchases
https://docs.adapty.io/docs/quickstart
MIT License
95 stars 17 forks source link

Adapty.purchaserInfoUpdateStream not getting renew events #31

Closed aaronvargas closed 2 years ago

aaronvargas commented 2 years ago

According to the docs at https://docs.adapty.io/docs/flutter-subscription-status section "Listening for subscription status updates" is seems that you should get subscription events (such as a renew event) via Adapty.purchaserInfoUpdateStream.listen((purchaserInfo)

But looking at the code, the only time anything is put on that stream _purchaserInfoUpdateController is when you explicitly call Adapty.getPurchaserInfo(). As it only adds to that stream in _handleIncomingMethodCall

I can also see that a background call to getPurchaserInfo() seems to happen every 1 minute in the background, but that doesn't update the purchaserInfoUpdateStream either... At least it doesn't for iOS test subscriptions that renew every 5 minutes.

2021-11-18 19:30:17.057-0800 [Adapty v1.16.3(1)] - INFO.
Calling now: getPurchaserInfo(forceUpdate:_:)

The Adapty.getPurchaserInfo() returns a Future with the current state, so it seems that Adapty.purchaserInfoUpdateStream should return new states as they happen. Do I have this wrong?

I could potentially also poll every minute (by calling Adapty.getPurchaserInfo()) for the current state... which seems redundant since you're already doing that.

AKyashkin commented 2 years ago

Hey, Adapty doesn't provide updates for Sandbox renewals, so that way SDK can't proceed with such notifications, but this is only a Sandbox issue. In production it works almost in realtime, since subscription periods are way longer than the test ones.

You can purchase something and receive updates via Adapty.purchaserInfoUpdateStream.listen((purchaserInfo) to make sure this method is actually working properly in terms of purchaserInfo changes.