[Solved] IAP progress save after cache clear

Hello!

I was working on my first commercial app, which generates the revenue using Unity Ads, but there’s also an option to buy a non-consumable IAP for $0.99, which will disable ads for good. Currently I’m using a CodeStage anti-cheat plugin to encrypt the PlayerPrefs, and store the purchase data locally (I know it’s still possible to hack it with a bit of effort, but this encryption is good enough for me). The only issue I’m having is that if I clear app cache on Android, it removes all the locally stored data, erasing all the information about the purchase, etc. This is a problem, because if the player were to start the app again later, they would notice that their purchase is gone, along with the high scores. I could care less about the high score, because they get a warning about them, but I’m worried about the legal issues that the returning ads and the “Free version” pop-up would cause after the cache reset.

Below is an example of what my “Purchase” method does. (I’m using codeless IAP). ObscuredPrefs is the plugin’s secure version of PlayerPrefs.

// Removes the ad button and changes the version
public void BuyGame(){
ObscuredPrefs.SetString(versionKey, paidVersion);
btnRemoveAds.SetActive(false);
}

Is there a way of asking the Play Store and App Store whether the IAP has been purchased recently, or storing the information on some kind of external database? If so - how?

Thanks in advance,
Vlad

@VKBobyr

Yes, App Stores will store a permanent record of all non-consumable and certain subscription purchases. When a user re-installs your app, these products are Restored. For some stores, like Google Play, this process is automatic. For iOS, you must have a button that restores purchases.