Hello!
I just started using Unity IAP and have a question regarding “Restore Purchases”.
To restore purchases I have this method:
public void RestorePurchases() {
if(!IsInitialized()) {
return;
}
IAppleExtensions iosExtensions = storeExtensionProvider.GetExtension<IAppleExtensions>();
iosExtensions.RestoreTransactions((result) => {
if(result) {
// What do here??
}
else {
// And here??
}
});
}
-
My first question is: What am I supposed to do in the lambda of RestoreTransactions? Is this code called for every restored items or only ONCE after all items have been restored?
-
My biggest problem: I have a ProcessPurchase(PurchaseEventArgs args) and if I understand correctly, this method is called in 2 cases: A) When I explicitly request a buy via storeController.InitiatePurchase(product) and B) When I request a restore purchases via RestoreTransactions().
I want to display a success dialog when the user bought an item. Thus actually I want to show a dialog inside ProcessPurchase(). My problem: Since ProcessPurchase() is also called when I do a “Restore purchases”, I can’t just open a dialog inside ProcessPurchase().
Imagine if the user clicks on “Restore Purchases” and the system restores 3 items, then I would get 3 dialogs.
How can I show a dialog ONLY when the user made a buy and NOT on Restore Purchases?