Revenuecat Entitlements Gate

RevenueCat/ai-toolkit/revenuecat/skills/revenuecat-entitlements-gate

作者 RevenueCatccfc038185ec457b2ac9077f3bbf1ba947a44dbb无许可证收录于 2026年10月9日更新于 2026年10月9日

Check whether a RevenueCat user currently has access to a paid feature via entitlements. Use when the user asks to gate a feature behind premium, check if the user has a pro subscription, read customerInfo active entitlements, show or hide a feature based on subscription status, react to entitlement changes, or 'is the user subscribed' on iOS, Android, Kotlin Multiplatform, Flutter, or React Native.

AI 生成的概览

指导如何检查 RevenueCat 权益,以便在 iOS、Android、KMP、Flutter 和 React Native 中为付费功能加门禁。

功能
该技能提供指导,用于根据有效的 RevenueCat 权益判断用户当前是否有权访问某项付费功能。内容涵盖平台识别、权益标识符与 customerInfo.entitlements.active 等通用概念,以及各支持平台上的一次性检查与响应式监听。它产出的是基于各平台参考文件的实现指引,而非可直接运行的代码。
适用场景
当需要根据订阅状态显示或隐藏功能、从 customerInfo 读取有效权益,或对权益变化做出响应时使用。适用于 iOS、Android、Kotlin Multiplatform、Flutter 和 React Native 项目。购买流程与用户识别由其他技能负责。
运行要求
无脚本,仅为说明性内容。需要已集成 RevenueCat SDK 且已执行 Purchases.configure 的项目,并能访问 RevenueCat 后台以确认权益标识符。平台参考文件从技能目录中读取。

revenuecat-entitlements-gate: check a RevenueCat entitlement

Use this skill when the user wants to decide whether to show or hide a feature based on an active RevenueCat entitlement. The skill covers the one shot check and the reactive listener; it does not cover purchasing (see revenuecat-purchase-flow) or auth (revenuecat-identify-user).

1. Detect the platform

Inspect the working directory and pick the first match, from top to bottom:

  1. React Native: package.json has a react-native-purchases entry, or react-native as a dependency → read platforms/react-native.md. If expo is also a dependency, note it as an Expo project.
  2. Flutter: pubspec.yaml exists at the project root → read platforms/flutter.md.
  3. Kotlin Multiplatform: build.gradle.kts contains a kotlin { … } multiplatform source sets block, or depends on com.revenuecat.purchases:purchases-kmp* → read platforms/kmp.md.
  4. Android (native): build.gradle(.kts) applies com.android.application (and is not KMP) → read platforms/android.md.
  5. iOS (native): Package.swift, *.xcodeproj, *.xcworkspace, or Podfile at the project root → read platforms/ios.md.

If several match (e.g. an ios/ folder inside a Flutter project), pick the outermost project, the one that owns the build. If still ambiguous, ask the user which platform they want to configure.

2. Shared concepts (all platforms)

  • Check the entitlement identifier, not the product ID. The identifier (for example "premium") is configured in the RevenueCat dashboard and mapped to one or more products. Using the entitlement lets you change products, prices, and stores without touching app code.
  • customerInfo.entitlements.active is the source of truth. It is a Map<String, EntitlementInfo> keyed by entitlement identifier. Presence in active means the user currently has access. Absence means they do not, regardless of past purchases.
  • Do not gate on purchase history. Expired subscriptions still appear in customerInfo.entitlements.all but drop out of active. Use active only.
  • Fetch once, then subscribe. The first customerInfo call returns a cached value quickly, and the SDK refreshes in the background. Every SDK exposes a listener or stream that fires when entitlements change (after a purchase, restore, renewal, or expiration). Subscribe to that instead of polling.
  • The SDK must be configured first. If Purchases.configure(…) has not run, the entitlement call will fail. Set up the SDK via integrate-revenuecat before using this skill.

3. Implementation

Read the platform file that matches detection:

  • platforms/ios.md
  • platforms/android.md
  • platforms/kmp.md
  • platforms/flutter.md
  • platforms/react-native.md

Each platform file shows the one shot check, the reactive subscription, and where to place each in a typical app.

4. Verify

Do not claim the gate works until:

  1. A user with an active entitlement sees the gated feature, and a user without it does not.
  2. When the entitlement state changes (test with a sandbox purchase or a manual grant in the dashboard), the UI updates without a manual restart, confirming the listener is wired.
  3. The entitlement identifier in the code matches an identifier that exists in the RevenueCat dashboard. A typo here silently gates everyone out.

来源与署名

来源:RevenueCat/ai-toolkit位于revenuecat/skills/revenuecat-entitlements-gate提交ccfc038

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架