queryPurchases() vs queryPurchaseHistoryAsync() in order to 'restore' functionality?
You should use queryPurchases
. That gives you all the current active (non-consumed, non-cancelled, non-expired) purchases for each SKU.
queryPurchaseHistoryAsync
won't do what you need because it will only give you a list of the most recent purchases for each SKU. They may have expired, been cancelled or been consumed, and there's no way to tell. Therefore this response can't be used to tell what purchases to apply in your app.
So far as I can see, the only valid use for queryPurchaseHistoryAsync
is to provide a user with a list of their purchase history. It's a bit of an oddball.
Note also: queryPurchases
is synchronous so in most cases it needs to be run in some kind of background worker thread. I run mine in an AsyncTask
.
Per documentation queryPurchases
uses the Play Store app cache to get the results while queryPurchaseHistoryAsync
actually checks the Purchase AP for the most recent purchases. So, in your case you should check the Async
method.
queryPurchases
Get purchases details for all the items bought within your app. This method uses a cache of Google Play Store app without initiating a network request.
queryPurchaseHistoryAsync
Returns the most recent purchase made by the user for each SKU, even if that purchase is expired, canceled, or consumed.
Also, make sure to check the documentation. It recommends to Cache purchase details on your servers
.
https://developer.android.com/google/play/developer-api.html#practices