Reinstall paid subscription to new Android device

I have an inapp subscription. I am trying to insure reinstallation of the application on the same or new, recognizing that the user has a valid subscription. The "already owned" answer is assumed to have a value of "7", which works great for consumable, managed products. However, for the subscription, I do not get the answer "7". Messages are also different. For a managed, consumed product, the message "The item already belongs" with the answer "7". To subscribe, the message "You already have this item", without a response of "7", and the IAB result is "-1005: User canceled." Google Wallet subscription promotion has not been canceled. I get an answer, I suppose, from being dismissed from a warning window.

The question is, how do I find out this answer on IABsetup? I tried if request.mResponse = 1, but this does not work. I obviously do not get a useful subscription response code. During testing, I have to disable debugging to load .apk, so this is even harder to complete.

Why is the response to the server from the server different from the response of the managed product for the elements that already belong to it?

I need to activate the application based on an existing answer.

Thanks.

0
android in-app-billing subscription
source share
1 answer

I found that IabHelper.java has the following:

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 response code goes to

 public void onIabPurchaseFinished(IabResult result, Purchase info) 

therefore, I can determine whether the response will cancel the dialog and allow the active subscription to be reinstalled and communicate with my server. At this point, I am making a call to the 0Auth API on Google to verify the installation and the active subscription.

There may be alternative ways to do this, but it worked.

Hope this helps three people in the world who are subscribing to Android inapp.

+2
source share

All Articles