简体   繁体   English

应用内购买产品检查

[英]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. 我已成功在我的应用程序中实现了应用程序内购买功能,并且它完美地在DEBUG模式下工作。

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. 1)如果没有购买,某些功能将被禁用。 2) After making the purchase, some features will be enabled. 2)购买后,将启用某些功能。

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. 还有一个IabHelper类,它是应用内结算API的包装,使事情变得更加简单。 Here's a snippet of code using the IabHelper . 这是使用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
      }
   }
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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