Reputation: 1
I'm using the in-app-purchase package in order to allow users to purchase non-consumables in my app. I have a method called listenForPurchases() that is called within the void initState() method which looks like so:
Future<void> listenForPurchases() async {
print ("Called listenForPurchases method");
iap.purchaseStream.listen((List<PurchaseDetails> purchases) async {
print ("Listened");
bool purchaseStatus = await purchaseProducts().handlePurchase(
purchases);
if (purchaseStatus == true) {
for (int i = 0; i < purchases.length; i++) {
print("User has " + (purchases[i].status.toString()) + " " +
purchases[i].productID);
if (purchases[i].status == PurchaseStatus.purchased){
print ("NEW Purchase was made");
//Logic here
await iap.completePurchase(purchases[i]);
} else if (purchases[i].status == PurchaseStatus.restored) {
print ("Restore was made");
//Logic here
}
}
}
});
}
As soon as my application starts, restore purchases is called:
await iap.restorePurchases();
On Android this works fine and I can see all purchases restored. But on iOS, when I try to restore, firstly, it picks up all the items as a new purchase first and then restores them afterwards.
My question is, why when I try to restore purchases on iOS, why do they come through as new purchases and then they are also then picked up as restores?
I've can't think of a reason why this is an issue specific to iOS and not Android and I'm not sure what to do from here. It's worth saying that this issue also happens with the app version deployed onto TestFlight.
Upvotes: 0
Views: 612