2

I have been trying to check if a user has subscribed a google product of my app. I have tried the following ways:

Bundle ownedItems = mService.getPurchases(3, getPackageName(),
            "inapp", null);
    if (ownedItems != null) {
        int response = ownedItems.getInt("RESPONSE_CODE");
        if (response == 0) {
            ArrayList ownedSkus = ownedItems
                    .getStringArrayList("INAPP_PURCHASE_ITEM_LIST");

This always returns ownedSku count as 0 (ie, no subscribed items are returning from play service)

also

 isSkuPurchased = inventory.hasPurchase("MY_SKU_VALUE"); 

By this way, if my product is not available in inventroy for purchase. But this always return true. (ie, the item is still not purchased)

I have been testing this with logs in alpha releases. Please help me here. I wonder is there a way to get the subscribed products from play service?

Any help is appreciated. Thanks in Advance!!

Kannan_SJD
  • 1,022
  • 2
  • 13
  • 32

1 Answers1

3

There are two types of products: managed in-app products and subscriptions.

If its a subscription rather than a managed in-app product, you should query for active subscriptions, use the getPurchases method, with the product type parameter set to "subs".

Bundle activeSubs = mService.getPurchases(3, "com.example.myapp",
                   "subs", continueToken);

The call returns a Bundle with all the active subscriptions owned by the user. Once a subscription expires without renewal, it will no longer appear in the returned Bundle.

random
  • 10,238
  • 8
  • 57
  • 101
  • Thanks for the help Random.. Will try now and let you know.. I do not have a continue token hope that does not affect – Kannan_SJD Nov 12 '15 at 06:06