This code was generated inside Visual Studio when implementing the Restore button for the IAP on iOS.
}
What are the meanings of the param1 and param2 ?
If param1 is true, does it mean the transaction was restored successfully ?
This code was generated inside Visual Studio when implementing the Restore button for the IAP on iOS.
}
What are the meanings of the param1 and param2 ?
If param1 is true, does it mean the transaction was restored successfully ?
Here’s the scripting documentation, search for RestoreTransactions:
https://docs.unity3d.com/Packages/com.unity.purchasing@4.7/api/UnityEngine.Purchasing.IAppleExtensions.html
If the boolean returns true it means that your app received all products it should restore. That does not mean that all restores are done yet - it simply means that the restore request finished.
Apple requires users to be able to restore transactions in case e.g. they replace a device. Users should be able to restore all the transactions on the new device.
Which would be the code snippet to verify if a specific product was already bought and restore it ? For codeless IAP.
Hello ShinyOpal,
For Codeless, all you need to do is add a Restore Button to handle the restore transactions.
There’s currently no way to verify if a specific product was already bought and restore it.
The restore transactions button will restore transactions for every products.
Just to clarify, restore purchases for ONLY non-consumable?
When a user reinstalls your application they should be granted any Non-Consumable or renewable Subscription products they already own. App stores maintain a permanent record of each user’s Non-Consumable and renewable Subscription products which Unity IAP can retrieve. Non-renewing subscriptions on Apple platforms cannot be restored. If you use non-renewing subscription products on Apple platforms, it is up to you to keep a record of the active subscriptions and sync the subscription between devices.
https://docs.unity3d.com/2018.1/Documentation/Manual/UnityIAPRestoringTransactions.html
Was not expecting this behaviour. There should be a way to know which product was restored. This would be needed in order to enable certain features of the app, just as if the user bought the app. Right now this is not possible. In my case I would need it for the non-consumable product. Can’t Unity create another OnTransactionsRestored where the list of the restored products is received as input ? That would be the expected solution.
The restored transactions are treated the same as a regular transaction. These will all make their way to your ProcessPurchase the same way as if the user bought the app.
Would this be sufficient for your case, where you receive your restored non-consumable during the ProcessPurchase and can then enable the features if it’s a valid restored purchase?
If not, could you provide more details so we can help you better with your case?
The reason this isn’t done is because we lack information about what is part of the restore transaction and we don’t know when Apple is done sending restored transactions since these are all received by the same transaction observer. We will investigate this to see if we can find a better solution.
Are you trying to say to add the OnPurchaseComplete(Product product) on the Restore button instead of the OnTransactionsRestored(bool param1, string param2) ? If this functions properly, that could be the solution.
It the user did not buy the product and clicks on the restore button, the OnPurchaseComplete will not be invoked, right ?
That is correct, OnPurchaseComplete will be invoked when restoring the product if it was purchased previously and it is still active.
For the products that were not bought, these won’t invoke the OnPurchaseComplete. Apple won’t send anything for those since there was no purchase.
Just tried it out. Unfortunately it is not possible to assign the OnPurchaseComplete to the Restore button. Unity does not display it in the list of methods as it does with the Purchase button.
The OnPurchaseComplete from the IAPButton and IAPListener will be called when the transaction is restored, the same way a regular purchase is made.
That means that a solution via the UI is not possible. Attached you can also find that the Unity Editor does not show OnPurchaseComplete in the UI, even though it exists in the script.
That would mean that a programmatic solution needs to be done.
I can access the restore button from the script
public IAPButton restoreButton;
The restore button has the following property
[Tooltip ("Event fired after a successful purchase of this product.")]
public OnPurchaseCompletedEvent? onPurchaseComplete;
Now the question is how to assign it ? Do you have a code sample ? Should I create a class which inherits from the OnPurchaseCompletedEvent ? How should this class look like ?
Maybe adding the event listener on the
restoreButton.onPurchaseComplete.AddListener(OnPurchaseComplete)
The OnPurchaseComplete is the existing method also used by the Buy button.