我可以通过Android应用中的Google Play一次购买多件商品吗? [英] Can I purchase multiple items at one time through Google Play in Android App?

查看:312
本文介绍了我可以通过Android应用中的Google Play一次购买多件商品吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我看来,我一次只能在Google App中购买一项.

代码A来自项目play-billing-samples,您可以看到解决方案

用户只能拥有一次相同的应用内商品,但可以同时拥有不同物品.

其他解决方案是将该项视为消耗品:

如果billingClient.consumeAsync()在购买过程结束时被调用,那么他可以再次购买同一物品,但是您必须跟踪他以自己的方式(可能是通过后端服务器)购买了多少次.

In my mind, I can only puchase one item at one time in Google App.

The Code A is from the project play-billing-samples, you can see here.

purchases: MutableList<Purchase> maybe exist multiple items, it seems that I can purchase these items simultaneously through Google Play, right?

Code A

override fun onPurchasesUpdated(
        billingResult: BillingResult,
        purchases: MutableList<Purchase>?
) {
    when (billingResult.responseCode) {
        BillingClient.BillingResponseCode.OK -> {
            // will handle server verification, consumables, and updating the local cache
            purchases?.apply { processPurchases(this.toSet()) }
        }
        BillingClient.BillingResponseCode.ITEM_ALREADY_OWNED -> {
            // item already owned? call queryPurchasesAsync to verify and process all such items
            Log.d(LOG_TAG, billingResult.debugMessage)
            queryPurchasesAsync()
        }
        BillingClient.BillingResponseCode.SERVICE_DISCONNECTED -> {
            connectToPlayBillingService()
        }
        else -> {
            Log.i(LOG_TAG, billingResult.debugMessage)
        }
    }
}

解决方案

An user can own the same in-app item only once, but he can own different items at the same time.

Other solution is to consider the item as consumable:

if billingClient.consumeAsync() is called at the end of the purchase process then he can buy the same item again, but you have to keep track of how many times he bought it by your own means, probably through a backend server.

这篇关于我可以通过Android应用中的Google Play一次购买多件商品吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆