QueryPurchases () vs queryPurchaseHistoryAsync () in order to "restore" functionality?

I use the Play Billing library to launch and manage purchases, which in turn unlock additional features in the app. This part works.

However, the best way to "restore" purchases. Say, for example, the one who bought the application buys a new phone. Log in to the Play Store, download my app, and then find that the payment screen for the “update” is displayed. IOS has a specific method for this, but I don't know about it for Android.

My thoughts are to request the Play Store and confirm that the account has SUCCESSFULLY acquired this item if I then call the local update function in the application.

There seem to be two similar methods. But which one should I use in this scenario? Where did the user either wipe their phone or buy a new one?

queryPurchases ()? Or queryPurchaseHistoryAsync ()?

+4
source share
2 answers

The documentation queryPurchasesuses the Play Store app cache to get results, while it queryPurchaseHistoryAsyncactually checks AP purchases for the most recent purchases. So, in your case, you should check the method Async.

queryPurchases

Get procurement information for all products purchased in your application. This method uses the cache of the Google Play Store application without initiating a network request.

queryPurchaseHistoryAsync

, SKU, , .

, . Cache purchase details on your servers. https://developer.android.com/google/play/developer-api.html#practices

+1

queryPurchases. ( , , ) SKU.

queryPurchaseHistoryAsync , , SKU. , , , , . , , .

, queryPurchaseHistoryAsync - . .

: queryPurchases , - . AsyncTask.

0

Source: https://habr.com/ru/post/1692757/


All Articles