revenuecat-entitlements-gate
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineserevenuecat-entitlements-gate: check a RevenueCat entitlement
revenuecat-entitlements-gate:检查RevenueCat权限
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 ) or auth ().
revenuecat-purchase-flowrevenuecat-identify-user当用户希望根据活跃的RevenueCat权限决定是否显示或隐藏某功能时,可使用此技能。该技能涵盖一次性检查和响应式监听,但不包含购买流程(详见)或身份验证(详见)。
revenuecat-purchase-flowrevenuecat-identify-user1. Detect the platform
1. 检测平台
Inspect the working directory and pick the first match, from top to bottom:
- React Native: has a
package.jsonentry, orreact-native-purchasesas a dependency → readreact-native. Ifplatforms/react-native.mdis also a dependency, note it as an Expo project.expo - Flutter: exists at the project root → read
pubspec.yaml.platforms/flutter.md - Kotlin Multiplatform: contains a
build.gradle.ktsmultiplatform source sets block, or depends onkotlin { … }→ readcom.revenuecat.purchases:purchases-kmp*.platforms/kmp.md - Android (native): applies
build.gradle(.kts)(and is not KMP) → readcom.android.application.platforms/android.md - iOS (native): ,
Package.swift,*.xcodeproj, or*.xcworkspaceat the project root → readPodfile.platforms/ios.md
If several match (e.g. an 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.
ios/检查工作目录,从上到下选择第一个匹配项:
- React Native:中包含
package.json条目,或依赖react-native-purchases→ 查看react-native。若同时依赖platforms/react-native.md,则标记为Expo项目。expo - Flutter:项目根目录存在→ 查看
pubspec.yaml。platforms/flutter.md - Kotlin Multiplatform:包含
build.gradle.kts多平台源码集块,或依赖kotlin { … }→ 查看com.revenuecat.purchases:purchases-kmp*。platforms/kmp.md - Android(原生):应用了
build.gradle(.kts)(且非KMP项目) → 查看com.android.application。platforms/android.md - iOS(原生):项目根目录存在、
Package.swift、*.xcodeproj或*.xcworkspace→ 查看Podfile。platforms/ios.md
若存在多个匹配项(例如Flutter项目内包含文件夹),选择最外层的项目,即负责构建的项目。若仍有歧义,请询问用户要配置哪个平台。
ios/2. Shared concepts (all platforms)
2. 通用概念(所有平台)
- Check the entitlement identifier, not the product ID. The identifier (for example ) 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.
"premium" - is the source of truth. It is a
customerInfo.entitlements.activekeyed by entitlement identifier. Presence inMap<String, EntitlementInfo>means the user currently has access. Absence means they do not, regardless of past purchases.active - Do not gate on purchase history. Expired subscriptions still appear in but drop out of
customerInfo.entitlements.all. Useactiveonly.active - Fetch once, then subscribe. The first 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.
customerInfo - The SDK must be configured first. If has not run, the entitlement call will fail. Set up the SDK via
Purchases.configure(…)before using this skill.integrate-revenuecat
- 检查权限标识符,而非产品ID。标识符(例如)在RevenueCat控制台中配置,并映射到一个或多个产品。使用权限标识符可让您无需修改应用代码即可更改产品、价格和商店。
"premium" - 是唯一可信源。它是一个以权限标识符为键的
customerInfo.entitlements.active。出现在Map<String, EntitlementInfo>中表示用户当前拥有访问权限;未出现则表示无权限,无论过往购买记录如何。active - 不要基于购买历史管控权限。已过期的订阅仍会出现在中,但会从
customerInfo.entitlements.all中移除。仅使用active进行判断。active - 先获取一次,再订阅监听。首次调用会快速返回缓存值,SDK会在后台刷新数据。每个SDK都提供了监听或流,当权限发生变化时(购买、恢复、续订或过期后)会触发。请订阅该监听而非轮询。
customerInfo - 必须先配置SDK。若未执行,权限检查调用会失败。使用此技能前,请通过
Purchases.configure(…)完成SDK配置。integrate-revenuecat
3. Implementation
3. 实现
Read the platform file that matches detection:
platforms/ios.mdplatforms/android.mdplatforms/kmp.mdplatforms/flutter.mdplatforms/react-native.md
Each platform file shows the one shot check, the reactive subscription, and where to place each in a typical app.
查看与检测结果匹配的平台文件:
platforms/ios.mdplatforms/android.mdplatforms/kmp.mdplatforms/flutter.mdplatforms/react-native.md
每个平台文件展示了一次性检查、响应式订阅的实现方式,以及在典型应用中的放置位置。
4. Verify
4. 验证
Do not claim the gate works until:
- A user with an active entitlement sees the gated feature, and a user without it does not.
- 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.
- The entitlement identifier in the code matches an identifier that exists in the RevenueCat dashboard. A typo here silently gates everyone out.
在满足以下条件前,请勿确认权限管控功能正常:
- 拥有活跃权限的用户能看到受管控的功能,无权限用户则看不到。
- 当权限状态变化时(通过沙盒购买或控制台手动授予测试),UI无需手动重启即可更新,确认监听已正确连接。
- 代码中的权限标识符与RevenueCat控制台中存在的标识符一致。此处的拼写错误会导致所有用户都无法访问该功能。