Comments (6)
I see. Yeah, behavior isn't ideal in this case.
We try not to wait for a server response because there's no guarantee that we'll actually get one - the user might have no connectivity, and waiting for a very slow network might lead to a bad user experience for people who actually paid.
There might be a middleground here, though. Maybe the SDK could provide, along with the purchaserInfo, some information that would indicate whether the purchaserInfo cache was outdated and it's trying to refresh it.
Or a separate method that only returns after refreshing (or a timeout).
Thoughts on how to handle this in the meantime:
-
get purchaser info earlier in the flow, before the paywall, and subscribe to purchaser info updates. This way you lower the chances of purchaser info being updated while the user is in the paywall.
-
alternatively, your app could wait until you get updated purchaserInfo or a timeout before you update the UI. This wouldn't be ideal, however, because you'd have to add the wait any time you query purchaser info, since as of right now the SDK doesn't provide a way of knowing if it's currently trying to update the cache.
from purchases-flutter.
Hi! 👋
This is a valid concern. We're trying to strike a balance here between getting the SDK to be as responsive as possible, while fetching new data if needed.
The SDK will cache purchaser info for 5 minutes (or until next app open, whichever happens first). Usually this isn't a problem, because purchaser info is updated at a slower rate than that (specially in production).
However, there are situations where the purchaser info could be out of date.
Our current approach to this is to:
- provide the cached info if available
- if it's stale (like in your case), return whatever we have so far (so that your app doesn't have to wait for us), then fetch from the backend, and inform the app as soon as results arrive.
In order to get that latest information as soon as it arrives, you can use the PurchaserInfoUpdateListener
. See https://github.com/RevenueCat/purchases-flutter/blob/develop/lib/purchases_flutter.dart#L64.
The idea is that you set up a listener function, and the SDK will call it whenever there are updates to purchaserInfo, triggered by any number of events, including detecting an outdated cache.
from purchases-flutter.
I just realized that you also had another ticket where you mentioned you were already using the purchaserInfoUpdateListener.
Is it not getting called after refreshing the cache? Otherwise, is there a situation that isn't covered by the combination of checking for purchaserInfo directly + the listener?
from purchases-flutter.
Hi!
Thanx for the response. Listener works as expected. But...
The use case here is as follows - user navigates to paywall where he can buy subscription. If user is already subscribed an image/text is shown a-la "You are already subscribed, thank you, etc" if not - button "Subscribe" is shown. And with current behavior it basically works. The "but" here is that if subscription status was changed in the meanwhile, user would briefly see "previous" state (because getPurchaserInfo returned cached data) until listener gets updated data and updates the UI accordingly. So there is this ugly UI "blink" (it is also hard to say how long user will be seeing the old state as it also depends on network latency, server response time, etc) - not the end of the world, but in this particular scenario I would prefer to show loader until I have most recent data.
Maybe separate method can be introduced (or flag of some sort added to current getPurchaserInfo) which waits for new data to arrive to tackle with such use cases. Or always trigger PurchaserInfoUpdateListener after the staleness check - even if there is no data change (mb with flag hasChanges: false), so there will be a possibility to set loader before calling getPurchaserInfo and then switching it off on listener callback.
from purchases-flutter.
Thanx for the response!
For now I will go with suggestion nr.1. But it would be great if SDK provided more "reliable" way of achieving that at some point in the future.
from purchases-flutter.
Thanks for the feedback, and for the patience on this. I agree that there are better ways for the SDK to provide this information. Hopefully we'll improve this soon.
Closing this ticket in the meantime.
from purchases-flutter.
Related Issues (20)
- no built in Android HOT 3
- MacOS two factor window is sized wrong and is jumpy, see video HOT 5
- Expiration date is same as purchase date (macOS) HOT 4
- Preload paywalls HOT 2
- The content behind the paywall reacts when users click on the paywall background. HOT 3
- latest version Fails for macOS HOT 3
- iOS Are there any plans to add Privacy Manifests? HOT 7
- Paywall Fullscreen template renders off center for ios HOT 4
- Dart Support HOT 2
- iOS lifetime purchase (non-consumable) never expired in sandbox HOT 5
- invalidateCustomerInfoCache not working (customer info is not updating still cached) HOT 3
- getOfferings not work HOT 11
- macOS purchases ui flutter registrant error and paywall opening not supported HOT 2
- Caught `Couldn't find package` exception when purchasing promotional offer HOT 5
- Transfer to new App User ID doesn't sync Firebase Integration HOT 1
- Crashes on iOS 17.3+ HOT 5
- Support custom Paywall view modes HOT 3
- Android is all of a sudden DEAD - getCustomerInfo doesn't work and getOfferings HOT 7
- Paywall doesn't show trial text HOT 3
- Paywall doesn't have configurable close button color HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from purchases-flutter.