How to implement recovery if I uninstall and reinstall the application

I have implemented an application for Google Play. I have a DungeonsRedux sample. here

restoreTransactions(); 

I know there is a way to recover transactions. But if I uninstall my application and reinstall it again, "how do I know if I bought an item?" I implemented purchase and recovery in an Amazon app, but in amazon I got an Amazon SDK that stores a record of a purchase transaction for a test account. How to achieve this on Google Play (recovery option)

Do I need to create an account on Google Play in order to receive a response to recovery? if so, so I tried to create a test account on Google Play.they ask for money. If not, then there is an SDK for the answer. Please, help.

+4
source share
2 answers

I suggest you test it first with an example application. Here is how you can test it. This will take care of your recovery problem as soon as you look at the sample application below.

Step 1. Install the sample application - TrivialDrive

Step 2. Now test with Static Responses: there are 4 buttons on Mainactivity, replace the button code with these reserved product identifiers.

  • android.test.purchased
  • android.test.canceled
  • android.test.refunded
  • android.test.item_unavailable

To use these reserved product identifiers, you do not need to add elements to the console application for developers. Here is a link to test your application.

After you have tested using the above method, you are ready to test your own product. Below is a detailed Turkish link for this. Testing in-app purchases using custom product identifiers

0
source

I am not an expert, but I will try to help here. I believe that in order to recover your purchased items you will need the SKU of the purchased items. And to pass the test that you will need to create real SKUs for your application. You can do this by adding your signed apk to beta testing and adding details to store listings. After that, you can add information about your purchased products in the "Products for applications" section. By doing so, you assign a Title, Description, Cost, and SKU (Product Identifier) ​​for each item you purchase in your application. Now, to recover your items, you need to have SKU of purchased items, etc.

You can do this by following these steps:

  • To complete all the steps, follow these steps, but you will need your signed apk to test the functionality (you will upload the same to the developer console).
  • In the IabHelper class, create your own method, call it getPurchasesDetail (). Use the following lines of code in this method:



 Bundle ownedItems=mService.getPurchases(3, mContext.getPackageName(), "inapp", null); ArrayList<String> ownedSkus=new ArrayList<String>(); int response = ownedItems.getInt("RESPONSE_CODE"); if (response == 0) { ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST"); } 

code>

Now the above lines will provide you with a list of purchased items in the array, enter the return type for your method and get it in your class where you need to restore purchases.

  • In your class, where you want to restore your purchases, follow these steps:



 iabHelper=new IabHelper(this, "you public here"); iabHelper.startSetup(new OnIabSetupFinishedListener() { @Override public void onIabSetupFinished(IabResult result) { if(result.isSuccess()) { try { ownedSkus=iabHelper.getPurchasesDetail();//get purchase list //Now you have the purchased SKU list in an arraylist, you can use SharedPreferences or something else for the further process. } catch (RemoteException e) { e.printStackTrace(); } } } }); 

code> 4. Now download the signed apk with this code and the public key in the developer's console (at the beta testing stage) and use the same apk to verify the execution that has been completed so far. But, buy items before restoration, do not forget to do it.

Hope this helps. Thanks.

0
source

All Articles