IAP consumable purchase recovery after re-install/new phone

Is there some detailed help/tutorials available, or could somebody help out, with how you go about handling consumable purchase history if somebody deletes an app, then later re-downloads it - or even just moves to a new phone.

Like, if your game has a… “50 coins” “100 coins” “500 coins” set of purchases.  A player buys 3 lots of 100 coins.  And they spend 150 of them to unlock something in the game, maybe to unlock a new spriteset or whatever they can spend those coins on.

And then they get a new phone…

On both Google, and Apple, how do you go about getting that data back?  How do you get their account back to 150 coins, and grant them whatever client-side things they’d unlocked with those consumable purchases?

Is there a simple/nice example set of code out there which handles this all smoothly in an easy to understand manner, please, or can somebody help with how to handle this?

Thanks!

Regrettably no. There is no quick and simple solution.

With Google, you need to explicitly tell that a consumable product has in fact been consumed, otherwise Google won’t let the user purchase that IAP again until it has been consumed. For Amazon and Apple, I believe that these purchases are consumed as soon as the user’s transaction finishes. Once a product, like your currency, has been consumed, the app stores don’t manage it any more and so loss of local data means loss of in-game currency as well.

This means that if you want to track users’ in-game currencies, then you need some backend service to store users’ data. This of course requires the users to register to whatever system you are using, be it your own server or some third party service.