Saving and restoring purchases

When dealing with consumable items it is your responsibility to save any data relating to them. For example, let's imagine you create an app with 10 mini games. You may initially want to let the user play 2 of those mini games. To access the other 8 mini games the user will need to purchase keys. You give the user an option to buy a key as a consumable item. If the user purchases a key they can unlock any of the locked mini games. Given this scenario you would need to store how many keys the user has purchased and whether they have used them to unlock any of the mini games. If they unlock a mini game then that particular key gets used up. To unlock any of the remaining mini games they either use some remaining keys or purchase new ones.

Consumable items are used after purchase. A user cannot get these items back if they uninstall your app or install the app onto another device.

Non-consumable items give you permanent access to something. For example, you may release a game that lets the user play the first 10 levels for free. If they want to access the remaining levels they can be unlocked through a non-consumable in app purchase. If the user uninstalls this app or moves it to another device they will still own the item.

On Android and Amazon platforms a call to InAppPurchaseSetup will automatically restore non-consumable items.

On iOS if a user purchased a non-consumable item then reinstalled the app then GetInAppPurchaseAvailable would return 0 for items unless it was purchased again. The user can still go through the purchase process without being charged, however, Apple has a requirement where you must display a button that allows users to restore purchases of non-consumable items. If this button is pressed any previous purchases will be restored without the user needing to run through the process of a full purchase. To handle this on iOS simply call InAppPurchaseRestore.