Ravi
Ravi

Reputation: 35559

subscribed in-app renewal broadcast in android

I have implemented in-app purchase for subscription product, It's working fine. I have set 1 month subscription for each product, and it will get renew after 1 month.

Now my question is does there any way to get renewed product list and renewal date?

Does google provide any kind of service or event through which we can get to know about renewal.

Upvotes: 9

Views: 791

Answers (2)

Ravi
Ravi

Reputation: 35559

Didn't get answer but got something which i am sharing with you all. After lots of research i came to know that there is no broadcast or service through which we can know that product is renewed or canceled.

With the use of billingService.getPurchases i got all purchases of current user.

Bundle bundle = billingService.getPurchases(3, getPackageName(), "subs", null);

This give me list of subscribed items with following details.

 INAPP_PURCHASE_ITEM_LIST
 RESPONSE_CODE
 INAPP_PURCHASE_DATA_LIST
 INAPP_DATA_SIGNATURE_LIST

from above details i got aurenew status, purchase date , orderId, packageName, purchaseTime, purchaseState, purchaseToken.

from all information atleast i can know when product was purchased, weather autorenew is on/off.

If user will cancel autoRenew from Google Play Store, his/her cycle chain will be complete and will get benefits until subscription end date.

after reaching end date of subscription if autoRenew is false, user will not get any benefits related to that product/purchase/subscription.

Upvotes: 1

meynety
meynety

Reputation: 561

Unfortunately, the In-app Billing API v3 does not provide any event or kind of way to be notified of subscription renewal or cancelation.

The only thing that you can do is manually query the API to retrieve the currently activated subscription. (This is valid for the Android API as well as the http based ones…)

The way to do this is from an Android client is :

  • Query the inventory as you usually do to get the list of products with IabHelper#queryInventory(boolean querySkuDetails, List<String> moreItemSkus, List<String> moreSubsSkus)

  • If the user has an active subscription, you will be able to get the purchase about it with IabHelper#getPurchase(String sku). The purchase will contain the information about the subscription state and time. (doc here)

To do this with the Google Play Developer API (from your serveur), you have to use get, the informations will be in the ressource returned.

Upvotes: 6

Related Questions