【问题标题】:Android IAB V3 Querying owned items returns positive but on consume returns item not ownedAndroid IAB V3 查询拥有的项目返回正数,但使用返回项目不拥有
【发布时间】:2013-04-19 11:08:47
【问题描述】:

我在我的应用程序中引入了 android IAB V3。在购买和消费物品后立即查询拥有的物品时,IABHelper 返回我仍然拥有该物品。但是在调用消费时,它会返回该项目不属于自己。我在下面给出我的 logcat 输出。

04-19 15:57:43.668: D/IabHelper(2757): Starting async operation: refresh inventory
04-19 15:57:43.678: D/IabHelper(2757): Querying owned items...
04-19 15:57:43.688: D/IabHelper(2757): Package name: com.games.mygame
04-19 15:57:43.688: D/IabHelper(2757): Calling getPurchases with continuation token: null
04-19 15:57:43.728: D/IabHelper(2757): Owned items response: 0
04-19 15:57:43.758: D/IabHelper(2757): Sku is owned: com.games.pack1
04-19 15:57:43.768: D/IabHelper(2757): Continuation token: null
04-19 15:57:43.768: D/IabHelper(2757): Querying SKU details.
04-19 15:57:43.838: D/IabHelper(2757): Got sku details: SkuDetails:{"title":"Coin Pack 1 (My Game)","price":"Rs. 105.69","type":"inapp","description":"Pack of 50000 coins.","productId":"com.games.pack1"}
04-19 15:57:43.838: D/IabHelper(2757): Ending async operation: refresh inventory
04-19 15:57:46.931: D/IabHelper(2757): Ending async operation: 
04-19 15:57:46.931: D/IabHelper(2757): Starting async operation: consume
04-19 15:57:46.931: D/IabHelper(2757): Consuming sku: com.games.pack1, token: wykaaffjpwmehhfdkgmzsbpb.AO-J1OxWZjidethjntgfks3C1tpo6TfiMgWyAc8ycTZWsr7UcaHidKIFRaH-K6L_aa2SYGFc3mq8kLBVajj3mtXQcw8oy8-GAT8aSBLJA_aP3AsnjEKSQ1Ot0OqTBDKJWRduiz
04-19 15:57:47.642: D/IabHelper(2757): Error consuming consuming sku com.games.pack1. 8:Item not owned
04-19 15:57:47.642: D/IabHelper(2757): Ending async operation: consume

我必须等待几分钟才能再次购买此商品。这是因为 google play 的本地缓存。有没有人遇到过这个问题。谁能告诉我可能出了什么问题以及如何解决。

【问题讨论】:

    标签: android in-app-billing


    【解决方案1】:

    答案在应用内结算文档http://developer.android.com/google/play/billing/api.html#consume

    这是由本地缓存引起的。 由于 Google Play 客户端现在在设备本地缓存应用内结算信息,因此您可以使用版本 3 API 更频繁地查询此信息,例如通过 getPurchases 调用。与以前版本的 API 不同,许多第 3 版 API 调用将通过缓存查找而不是通过与 Google Play 的网络连接来提供服务,这大大加快了 API 的响应时间。这就是为什么他们建议根据消费函数的响应而不是根据拥有的物品来奖励购买的物品。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-23
    • 1970-01-01
    • 2010-10-26
    • 1970-01-01
    • 2016-03-12
    • 1970-01-01
    • 2020-05-15
    • 2017-12-31
    相关资源
    最近更新 更多