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 從公開儲存庫中收錄這些內容。

檢舉或申請下架