3

I have the following situation:

A user purchases a subscription on an app on his device A. Later on, he buys a device B and configures it with the same account of device A. He installs that same app on device B, but the purchase he made on device A is not available there.

What can I do to make device B recognize the purchase? I tried using BillingClient#purchaseHistoryResponseListener, but even though it really returns the most recent purchases, it is not possible to say if the purchase is active (if it as a SUBS) or if it is not consumed yet (if it is a INAPP).

Augusto Carmo
  • 4,386
  • 2
  • 28
  • 61

1 Answers1

8

If I am understanding your question correctly, you will have this information in queryPurchases(). As you already must know, this takes information from cache. So from device B you first need to make the queryPurchaseHistoryAsync() call, this refreshes the cache if this call is successful, and once it is, you can get the information you need in queryPurchases().

It has not been mentioned in the documentation that this method refreshes the cache, but this trick does seem to work for me and a bunch others if you refer here

esp
  • 146
  • 4
  • This issue thread has a different story https://github.com/android/play-billing-samples/issues/122 Wonder what is going wrong? – Rahul Kahale Dec 18 '20 at 17:28
  • Thank you for your answer. That is a much needed bit of detail to know that queryPurchases() is refreshed from queryPurchaseHistoryAsync(). – kralvarado May 25 '21 at 17:10