-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Callback function of addCustomerInfoUpdateListener() is not called on hot restart in development or on restart after OOM kill in production #1192
Comments
👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out! |
Same issue here |
Facing same issue! Even in prod, some users are reporting that they are not able to access the Premium features, which means that this callback is not getting triggered on initialization.
|
It is very likely to be true. It can be simulated with the following steps.
At the point of 4 above, the app behaves like it has restarted. However, because the callback is not called this time, the app cannot get the purchase information. A user with a valid subscription is treated as a free plan user. I need to avoid using the package versions with this bug for production. The latest version 8.2.1 still has the issue. |
Hi all, In a hot reload, the SDK remains configured so a new customer info is not sent. However, the flutter side caches are lost. In flutter, we cache the last customer info to send to the listener when a new listener is added, but that cached customer info is lost upon the hot reload so it won't call the new listener here. We're looking into the best way to fix this in the SDK, and will keep you updated. |
My current workaround is to avoid relying solely on the listener and manually use var wasListenerCalled = false;
Purchases.addCustomerInfoUpdateListener((info) {
wasListenerCalled = true;
_someHandler(customerInfo: info);
});
if (!wasListenerCalled) {
// getCustomerInfo() works fine even if the callback was not called
// on registration above due to the bug.
final info = await Purchases.getCustomerInfo();
_someHandler(customerInfo: info);
} It seems the listener of |
Environment
flutter doctor
purchases-flutter
print('Some message.');
in the callback function ofaddCustomerInfoUpdateListener()
.Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)
Describe the bug
The callback function of
addCustomerInfoUpdateListener()
used to be called both on app start and on hot restart. I have confirmed it with purchases_flutter 8.1.0. I upgraded the package to 8.1.6 today and found it is no longer called on hot restart.Additional context
It is really inconvenient that I need to kill and rerun an app to avoid the issue in debugging.
It looks like the callback function is not called when
restorePurchases()
is executed after a hot restart either.The text was updated successfully, but these errors were encountered: