getPurchaseHistory() and getAvailablePurchases() are not resolved / rejected
GuvanchBayryyyev opened this issue · 5 comments
Version of flutter_inapp_purchase
5.3.1
Platforms you faced the error (IOS or Android or both?)
both
Expected behavior
request should be resolved/rejected
Actual behavior
request not being resolved/rejected
Tested environment (Emulator? Real Device?)
Emulator and Real Device
Steps to reproduce the behavior
final history = await _iap.getPurchaseHistory();
final purchases = await _iap.getAvailablePurchases();
Similar issue
I think it is same issue as in React native this
The same problem on iPhone 14 ios 16.0 simulator, but on iPhone 8 ios 12.4 simulator it works
I have the same issue on iPhone 12 - iOS 16.
This happens when you are trying to call getPurchaseHistory()
and getAvailablePurchases()
on a development build and you are not logged in with a sandbox tester account on your device. Looks like the plugin isn't handling the errors and exceptions thrown by the two of above mentioned methods.
I have added a hack to my initializer, basically a race condition that skips this check if it takes too long.
List<PurchasedItem> storePurchases = [];
final result = await Future.any([
_plugin.getAvailablePurchases(),
Future.delayed(const Duration(seconds: 5))
]);
result != null ? storePurchases = result : storePurchases = [];
I then went to Settings -> App Store -> Scroll down to "Sandbox Account" and entered my sandbox credentials. The methods then started working fine.
If I am understanding this issue correctly, this is impossible to happen on release build on AppStore because the user will be always signed in with his/her Apple ID.
final history = await FlutterInappPurchase.instance
.getPurchaseHistory()
.timeout(Duration(seconds: 5), onTimeout: () => []);
is another way to skip
I have the same issue on iOS 16 (simulater, iPhone 14 max pro).
When it set correct account (Apple id and Sandbox account), getPurchaseHistory() and getAvailablePurchases() is responsed.
[case 1] => OK
apple id: hogehoge1@mail.com
sandbox: hogehoge1@mail.com
[case 2] => NG
apple id: hogehoge1@mail.com
sandbox: hogehoge2@mail.com
When Apple id and Sandbox account are different, the methods are not responsed.
[case 3] => NG
apple id: hogehoge1@mail.com
sandbox: (none)
Even if plugin version is 5.0.3, only iOS 16 have same issue.
In iOS 15 case, it doen’t have issue.
This issue is stale because it has been open 90 days with no activity. Leave a comment or this will be closed in 7 days.