[Solved] Restore IAP on iOS - Please help

I am trying to restore a non-consumable purchase on iOS using Unity-IAP.
I have only 1 IAP which is to remove ads. Apple request this can be restored and a button is required.
Below is the function I call on the button to restore purchases;

public void RestorePurchases()
{
// If Purchasing has not yet been set up …
if (!IsInitialized())
{
// … report the situation and stop restoring. Consider either waiting longer, or retrying initialization.
Debug.Log(“RestorePurchases FAIL. Not initialized.”);
return;
}

// If we are running on an Apple device …
if (Application.platform == RuntimePlatform.IPhonePlayer ||
Application.platform == RuntimePlatform.OSXPlayer)
{
// … begin restoring purchases
Debug.Log(“RestorePurchases started …”);

// Fetch the Apple store-specific subsystem.
var apple = m_StoreExtensionProvider.GetExtension();
// Begin the asynchronous process of restoring purchases. Expect a confirmation response in
// the Action below, and ProcessPurchase if there are previously purchased products to restore.
apple.RestoreTransactions((result) => {
// The first phase of restoration. If no more responses are received on ProcessPurchase then
// no purchases are available to be restored.
Debug.Log("RestorePurchases continuing: " + result + “. If no further messages, no purchases available to restore.”);
// Should I restore the IAP here??? *****

});
}

How do I know if the restore has been complete ‘sucesfully’ ?
Do I assume it has been and insert my codes where I have written ‘// Should I restore the IAP here??? *****’ above?

Any suggestion would be great welcomed.
Thank you

1 Like

The Restore function will call ProcessPurchase for any product that needs to be restored.

The process is described in our Manual:

2 Likes

So… Just create a new button in game call RestorePurchases() ?
How de program know ?

Which item is selected to call the purchase function?
Or do I have to do this? If so, where do I do it?

@renato-innocenti

You only need 1 Restore Purchases button and it will restore all the purchases that a user has made. You can put it anywhere you like: somewhere in the store itself, in an options menu, etc.

There is some example code for Restoring purchases in this tutorial:
https://unity3d.com/learn/tutorials/topics/ads-analytics/integrating-unity-iap-your-game

5 Likes