检查 RevenueCat 的用户订阅是否仍然有效 API

Check if Users Subscription is still active with the 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.

提供的过期时间进行比较