简体   繁体   中英

In-App Purchase Product Checking

What I have Done

I have implemented the in-app purchasing feature in my app successfully and it is working in DEBUG mode perfectly.

What I Want

Now as the purchase (one time only) has been made, now I need to enable some features in my app based on this.

1) If the purchase is not made, some features will be disabled. 2) After making the purchase, some features will be enabled.

I want to know how can I query or remember that the purchase has been made and the features should be enabled. What is the correct way of doing this.

Thanks.

Check the developer guide for in-app billing, especially the Query Purchased Items section.

There's also IabHelper class which is a wrapper around the in-app billing API to make things a little bit easier. Here's a snippet of code using the IabHelper .

IabHelper.QueryInventoryFinishedListener mGotInventoryListener 
   = new IabHelper.QueryInventoryFinishedListener() {
   public void onQueryInventoryFinished(IabResult result,
      Inventory inventory) {

      if (result.isFailure()) {
        // handle error here
      }
      else {
        // does the user have the premium upgrade?
        mIsPremium = inventory.hasPurchase(SKU_PREMIUM);        
        // update UI accordingly
      }
   }
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM