gpt4 book ai didi

android - 在 App Billing Library 中不提供消费 Purchase Item 后更新的 PurchaseList?

转载 作者:太空狗 更新时间:2023-10-29 13:03:42 24 4
gpt4 key购买 nike

我目前正在使用 In App Billing Library 在 App Purchase 中实现,

使用方法消耗购买的元素后:

mBillingClient.consumeAsync(purchaseToken, new ConsumeResponseListener() {
@Override
public void onConsumeResponse(int responseCode, String purchaseToken) {
if (responseCode == BillingClient.BillingResponse.OK) {
Toast.makeText(getApplicationContext(), "Item Consumed Successfully..." + purchaseToken, Toast.LENGTH_LONG).show();
}
}
});
break;

当我再次打开应用程序并想使用以下方法检索购买列表的列表时:

mBillingClient.queryPurchaseHistoryAsync(BillingClient.SkuType.INAPP, new PurchaseHistoryResponseListener() {
@Override
public void onPurchaseHistoryResponse(int responseCode, List<Purchase> purchasesList) {
if (responseCode == BillingClient.BillingResponse.OK) {
purchases = purchasesList;
retrieveItemList();
}
}
});

它还为我提供了我在列表中消费过的项目。所以,帮我找出我做错了什么来获得更新的购买 list 。谢谢。

最佳答案

您只需使用 queryPurchase 方法代替 queryPurchaseHistoryAsync,如下所示:

mBillingClient.queryPurchase(BillingClient.SkuType.INAPP, new PurchaseHistoryResponseListener() {
@Override
public void onPurchaseHistoryResponse(int responseCode, List<Purchase> purchasesList) {
if (responseCode == BillingClient.BillingResponse.OK) {
purchases = purchasesList;
retrieveItemList();
}
}
});

这两种方法的区别在于,queryPurchaseHistoryAync 会为您提供您一生中购买过的所有元素的列表,即使购买的元素已被使用;而 queryPurchase 将为您提供当前已购买商品的列表。

关于android - 在 App Billing Library 中不提供消费 Purchase Item 后更新的 PurchaseList?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51720111/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com