i have one non consumable item in my game which can be purchased, the no Ads purchase. I am using Codeless IAP and with that an IAP Button. My code looks like this:
public void OnPurchaseComplete(Product product)
{
if (product.definition.id == noAdsID)
{
PlayerPrefs.SetInt("isForcedAdsBought", 1);
else
{
Debug.Log("No product with ID: " + product.definition.id + " found");
}
}
public void OnPurchaseFailed(Product product, PurchaseFailureReason reason)
{
Debug.Log("Product with ID " + product.definition.id + "threw following error" + reason);
}
In the inspector of my IAP Button i made references to the code above.
Everything works fine, but i dont know how to handle a reinstall. Cuz all the PlayerPfrefs will be gone but google Playstore automatically restores the purchases. And Apple app store restores after the restore button had been pressed.
My question, how do i know if any purchases had been restored? I would like to be able to catch those informations and store them in the PlayerPrefs again.
@iboshido A Restore is just like a Purchase. ProcessPurchase is called for each product, write to PlayerPrefs at that time. Your code above should work. Please describe how your users are impacted during reinstall.
Ohh ok now i understand. It works now. I removed the references of the functions above out of the inspector of IAP Button. I created an IAP Listener and referenced it in the inspector to the code above. Now every time a purchase is been made or the playstore automatically restores data, the Listener will catch those calls. Thank you for your help
I haven’t tested it on iOS yet, but when is a iOS user allowed to push the restore button? And how often can he push this button? Will my IAP Listener work with iOS restore button?