使用RevenueCat API检查用户订阅是否仍处于活动状态



使用RevenueCat API检查用户订阅是否仍处于活动状态的最佳方法是什么?

我可以获得用户的权限,但在订阅到期后,权限似乎仍在权限对象中。

"entitlements": {
"premium_monthly": {
"expires_date": "2019-10-27T17:27:59Z",
"product_identifier": "app_premium_monthly",
"purchase_date": "2019-10-27T17:21:24Z"
}
},

我看到的唯一方法是这样的:

const exp = new Date(res.data.subscriber.entitlements.premium_monthly.expires_date)
const now = new Date();
if (exp.getTime() < now.getTime()) {
// Subscription is no longer valid
}

这是预定的方法吗?还是有更好的方法?

是的,这是检查它的方法。将当前时间与RevenueCat的API提供的过期时间进行比较。

相关内容

最新更新