[英]Flutter/Revenuecat: Check if user has already bought something
i am currently building an app in Flutter using RevenueCat for the in-app-purchases.我目前正在使用 RevenueCat 在 Flutter 中构建应用程序以进行应用程序内购买。
I now want to know for each user, if he has already made an in-app-purchase, since I have trial subscriptions activated.我现在想知道每个用户是否已经进行了应用内购买,因为我已经激活了试用订阅。 I need this information, because I want to adjust the UI in case a user registers with a new account that I haven't seen in RevenueCat so far.
我需要此信息,因为我想调整 UI,以防用户使用我目前在 RevenueCat 中未见过的新帐户注册。 In this case, he won't be able to use the trial subscription again, since Google/Apple prevent this.
在这种情况下,他将无法再次使用试用订阅,因为 Google/Apple 阻止了这种情况。
I am using a custom ID for every user in my app and I use this ID for RevenueCat aswell, one could just create a new account and get a different user id.我在我的应用程序中为每个用户使用自定义 ID,我也将此 ID 用于 RevenueCat,可以创建一个新帐户并获得不同的用户 ID。 In this case, this looks like a "new" user to RevenueCat which has no subscriptions.
在这种情况下,这看起来像是没有订阅的 RevenueCat 的“新”用户。 I think the solution would have to check the GooglePlay-Account for an already purchased subscription
我认为解决方案必须检查 GooglePlay 帐户是否已购买订阅
So far I have not found a way to find out, if a user has already made an in-app-purchase.到目前为止,我还没有找到一种方法来确定用户是否已经进行了应用内购买。 Any ideas on how to achieve this?
关于如何实现这一目标的任何想法?
I have tried to do this with https://pub.dev/packages/in_app_purchase , but no luck so far.我尝试使用https://pub.dev/packages/in_app_purchase来做到这一点,但到目前为止还没有成功。 All the guides seem to be outdated.
所有指南似乎都已过时。
Thanks.谢谢。
You can check Entitlements to determine if a user has an active subscription, more info here: https://docs.revenuecat.com/docs/customer-info您可以检查权利以确定用户是否有有效订阅,更多信息在这里: https ://docs.revenuecat.com/docs/customer-info
It will go something like:它会是这样的:
try {
PurchaserInfo purchaserInfo = await Purchases.getPurchaserInfo();
// access latest purchaserInfo
} on PlatformException catch (e) {
// Error fetching purchaser info
}
Then然后
if (purchaserInfo.entitlements.all["my_entitlement_identifier"].isActive) {
// Grant user "pro" access
}
based on official documentation基于官方文档
scenario Does not have any login mechanism and only relies on RevenueCat anonymous App User IDs.
方案没有任何登录机制,仅依赖于 RevenueCat 匿名应用程序用户 ID。
solution解决方案
Transfer purchases.
转移购买。 Required to allow customers to restore transactions after uninstalling / reinstalling your app.
需要允许客户在卸载/重新安装您的应用程序后恢复交易。
just set that in your revenueCat dashboard and it restores user purchases depending on只需在您的 revenueCat 仪表板中设置它,它就会恢复用户购买,具体取决于
google play account or apple id google play 帐户或apple id
for more info -> https://www.revenuecat.com/docs/restoring-purchases#example-usage了解更多信息 -> https://www.revenuecat.com/docs/restoring-purchases#example-usage
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.