#Preferred way to RestorePurchases

1 messages · Page 1 of 1 (latest)

wet jolt
#

In OnInitializeStoreComplete() you can currently query for products purchased (V2 did it this way and it still works this way in V3):

private void OnInitializeStoreComplete(BillingServicesInitializeStoreResult result, Error error) {
foreach (var product in result.Products) {
bool isProductPurchased = BillingServices.IsProductPurchased(product);
...

Or, you can explicitly wait for StoreComplete to finish, then call BillingServices.RestorePurchases() and do similar to the above in OnRestorePurchasesComplete().

Which is preferred?

Also, the docs say:

"It's always good to call Restore Purchases once you are done with InitializeStore call as the user will be available with unlocked content if he/she has purchased any earlier."

But Apple says you should not do automatically restore purchases unless the user presses the button. I am assuming if I use the new bool parameter in BillingServices.RestorePurchases(/forceRefresh=/false); it won't create a popup on IOS so it is OK to always do this.

south ridge
#

Thanks for the great question.

In v3, calling RestorePurchases on iOS with forceRefresh false will just pass the cached values(which are always maintained in sync by the os) .
But when you set forceRefresh to true, this will show up a login prompt for the user. This is the case apple stated in docs to have this call only when user explicitly wants to restore.

#

As we need to derive same func across platforms, we still retained RestorePurchases call and added forceRefresh param. This way, code in v2 is still compatible.