Nirav Dhanani
Nirav Dhanani

Reputation: 45

How can I verify user has already done in purchase In my Android App without open Purchase Dialog?

I have one application in that i have put In App Purchase when User open Application i check first time In Purchase happen or not using launchPurchaseFlow(using automatic call) because of this open Dialog of In App purchase(i am call this methode first time because suppose user have done in app purchase he is reinstalling App so check in Purchase happen or not this methode give response Already Purchase so i can know not to display add ) so how can i call this methode and ignore the in purchase dialog first time ? what change i do in launchPurchaseFlow methode of IabHelper.java Thanks in Advance....

Upvotes: 0

Views: 1287

Answers (1)

random
random

Reputation: 10309

You should query for purchased items instead of launchPurchaseFlow.

To retrieve information about purchases made by a user from your app, call the getPurchases method on the In-app Billing Version 3 service. Pass in to the method the In-app Billing API version (“3”), the package name of your calling app, and the purchase type (“inapp” or "subs").

Bundle ownedItems = mService.getPurchases(3, getPackageName(),
"inapp", null); 

The Google Play service returns only the purchases made by the user account that is currently logged in to the device.

To query for active subscriptions, use the getPurchases method, again with the product type parameter set to "subs".

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

Upvotes: 2

Related Questions