Google In App Billing区分用户帐户 [英] Google In App Billing differentiate user accounts

查看:56
本文介绍了Google In App Billing区分用户帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个包含In App Billing非消耗性产品(终身订阅)的应用.
用户的设备上有一封与Play商店相关的电子邮件.

I'm developing an app that contains In App Billing non consumable product (Life time Subscription).
User has one email associated with Play Store on his device.

场景:
用户A使用user1@test.com创建一个新帐户,并购买终身订阅"和注销".
用户B使用user2@test.com创建了一个新帐户并尝试购买.
但他得到了响应 BillingClient.BillingResponse.ITEM_ALREADY_OWNED .

我如何区分每个用户购买商品?
我正在使用'com.android.billingclient:billing:2.2.1'

推荐答案

如果使用Firebase身份验证,则可以使用 String uid = FirebaseAuth.getInstance().getCurrentUser().getUid()获取用户的唯一ID.,您可以在购买时使用此ID,例如-

If you are using Firebase authentication then you can get user's unique id using String uid = FirebaseAuth.getInstance().getCurrentUser().getUid() and you can use this Id at the time of purchase like -

BillingFlowParams billingFlowParams = BillingFlowParams.newBuilder()
                .setSkuDetails(skuDetails).setObfuscatedAccountId(uid)
                .build();
        BillingResult billingResult = billingClient.launchBillingFlow(activity, billingFlowParams);

还可以在数据库中使用此标识符作为唯一标识符,以检查用户是否具有订阅权限.

Also in your database use this as unique identifier to check whether user has the subscriotion or not.

这篇关于Google In App Billing区分用户帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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