Question

I have an inapp subscription. I am trying to insure the re-installation of the app on the same or a new will recognize that the user has a valid subscription. The "already owned" response is supposed to have a value of "7", which works fine for consumable, managed products. For subscriptions, however, I do not get a "7" response. The messages are different, too. For a managed, consumable product the message is "Item already owned" with a "7" response. For subscriptions the message is "You already own this item", with NO "7" response, and the IAB result is "-1005:User cancelled". The subscription is active in Google Wallet, has not been cancelled. I get the response, I believe, from the alert box dismissal.

The question is, how do I recognize this response to the IABsetup? I have tried if request.mResponse = 1, but that does not work. I aparently do not get a useful response code for subscriptions. During testing, I have to turn off debug to upload the .apk so this is even more difficult to follow.

Why would the subscription response from the server differ from the managed product response for already owned items?

I need to be able to activate the app based on the already owned response.

Thanks.

Was it helpful?

Solution

I discovered the IabHelper.java has this:

else if (resultCode == Activity.RESULT_CANCELED) {
        logDebug("Purchase canceled - Response: " + getResponseDesc(responseCode));        
        result = new IabResult(IABHELPER_USER_CANCELED, "User canceled.");
        if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null);
    }

I changed to this:

else if (resultCode == Activity.RESULT_CANCELED) {
        logDebug("Purchase canceled - Response: " + getResponseDesc(responseCode));        
        result = new IabResult(responseCode, "User canceled.");
        if (mPurchaseListener != null) mPurchaseListener.onIabPurchaseFinished(result, null);
    }

Note the change from (IABHELPER_USER_CANCELED, "User canceled.") to (responseCode, "User Canceled")

Now the responseCode is passing to the

public void onIabPurchaseFinished(IabResult result, Purchase info)

so I can determine if the response is a dialog cancel and allow the active subscription to re-install and contact my server. At that point I am doing the 0Auth API call to Google to verify the installation and active subscription.

There may be alternate ways to do this, but this worked.

Hope this helps the 3 people in the world who are doing Android inapp subscriptions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top