integrate-revenuecat

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

integrate-revenuecat: end-to-end RevenueCat integration

integrate-revenuecat:端到端RevenueCat集成

Use this skill when the user wants to add RevenueCat to a project for the first time, or to reconfigure the SDK with a public API key. The skill covers two halves:
  1. Dashboard side — set up the project, register the app, and obtain the public API key, all through the RevenueCat MCP server.
  2. App side — install the Purchases SDK, call
    Purchases.configure(…)
    at app entry, and verify the configuration banner in the logs.
Walk them in order. Most integrations need both halves, even when the user asks "just install the SDK" — the SDK needs an API key from the dashboard.
If a project + app already exist and the user only wants to wire the SDK into code, jump to Section 3 below. If the user wants to bootstrap a brand new RevenueCat project (apps + products + entitlements + offerings), use the
create-revenuecat-project
skill instead, then come back here for the SDK install.
当用户首次想要向项目中添加RevenueCat,或使用公开API密钥重新配置SDK时,可使用此技能。该技能涵盖两部分内容:
  1. 控制台端——通过RevenueCat MCP服务器完成项目设置、应用注册并获取公开API密钥。
  2. 应用端——安装Purchases SDK,在应用入口调用
    Purchases.configure(…)
    ,并验证日志中的配置横幅。
请按顺序执行这些步骤。大多数集成都需要完成这两部分,即使用户只要求“安装SDK”——因为SDK需要来自控制台的API密钥。
如果项目和应用已存在,且用户仅希望将SDK接入代码,请跳至下方的第3节。 如果用户想要搭建一个全新的RevenueCat项目(包含应用、产品、权益、产品套餐),请改用
create-revenuecat-project
技能,之后再回到此处进行SDK安装。

Arguments

参数

Available as
$ARGUMENTS
when invoked as a slash command:
  • platform
    (optional): One of
    ios
    ,
    android
    ,
    kmp
    ,
    flutter
    ,
    react-native
    . If omitted, run the detection algorithm in Section 3a.
  • app_identifier
    (optional): Bundle ID (iOS) or package name (Android). If omitted, read it from the project files (
    Info.plist
    ,
    AndroidManifest.xml
    ,
    app.json
    ,
    pubspec.yaml
    ).
  • project_name
    (optional): Name of the RevenueCat project to use. If omitted, list projects via MCP and ask the user.
通过斜杠命令调用时,可通过
$ARGUMENTS
获取以下参数:
  • platform
    (可选):可选值为
    ios
    android
    kmp
    flutter
    react-native
    。若未指定,则执行第3a节中的检测算法。
  • app_identifier
    (可选):Bundle ID(iOS)或包名(Android)。若未指定,则从项目文件(
    Info.plist
    AndroidManifest.xml
    app.json
    pubspec.yaml
    )中读取。
  • project_name
    (可选):要使用的RevenueCat项目名称。若未指定,则通过MCP列出项目并询问用户。

1. Understand the status quo

1. 了解当前状态

Before touching the dashboard, gather the facts:
  • Platform target: iOS / Apple App Store, Android / Google Play, or both. Inspect the working directory before asking — the detection algorithm in Section 3 makes this obvious for most projects.
  • Technology: native iOS (Swift), native Android (Kotlin / Java), React Native, Flutter, Kotlin Multiplatform. SDK list: https://www.revenuecat.com/docs/getting-started/installation.md.
  • App identifier: bundle ID (iOS), package name (Android). Pull from
    Info.plist
    /
    AndroidManifest.xml
    /
    app.json
    /
    pubspec.yaml
    rather than asking.
操作控制台之前,请先收集以下信息:
  • 目标平台:iOS/苹果应用商店、Android/Google Play,或两者皆有。操作前先检查工作目录——第3节中的检测算法可明确大多数项目的平台类型。
  • 技术栈:原生iOS(Swift)、原生Android(Kotlin/Java)、React Native、Flutter、Kotlin Multiplatform。SDK列表:https://www.revenuecat.com/docs/getting-started/installation.md。
  • 应用标识符:Bundle ID(iOS)、包名(Android)。优先从
    Info.plist
    /
    AndroidManifest.xml
    /
    app.json
    /
    pubspec.yaml
    中获取,而非询问用户。

2. Dashboard side — RevenueCat MCP

2. 控制台端——RevenueCat MCP

Use the RevenueCat MCP server for every tool call below.
以下所有工具调用均需通过RevenueCat MCP服务器完成。

2a. Get or create the project

2a. 获取或创建项目

  • list-projects
    — list accessible projects. If multiple, ask the user which one matches this app, or offer to create a new one.
  • If there is no project, hand off to the
    create-revenuecat-project
    skill, then resume here.
  • Store the
    project_id
    for the rest of the steps.
  • list-projects
    ——列出可访问的项目。若存在多个项目,请询问用户哪个项目与当前应用匹配,或提供创建新项目的选项。
  • 若不存在项目,请转交至
    create-revenuecat-project
    技能,之后再回到此处继续。
  • 保存
    project_id
    用于后续步骤。

2b. Get or create the app

2b. 获取或创建应用

  • Check which apps are already configured in the project. A
    test_store
    app is always present;
    app_store
    and
    play_store
    apps are present only if the user has finished store-side setup.
  • Ask the user whether their app is already set up in App Store Connect (iOS) or Google Play Console (Android). Reassure them that store-side setup can come later — the
    test_store
    app is enough to start integrating.
  • If the user confirms store-side setup is done, call
    create-app
    :
    • iOS:
      type: "app_store"
      ,
      bundle_id
      from Section 1.
    • Android:
      type: "play_store"
      ,
      package_name
      from Section 1.
    • name
      derived from the identifier or asked from the user.
  • 检查项目中已配置的应用。
    test_store
    应用始终存在;
    app_store
    play_store
    应用仅在用户完成商店端设置后才会存在。
  • 询问用户其应用是否已在App Store Connect(iOS)或Google Play Console(Android)中完成设置。请向用户保证,商店端设置可稍后进行——
    test_store
    应用足以启动集成工作。
  • 若用户确认已完成商店端设置,请调用
    create-app
    • iOS
      type: "app_store"
      bundle_id
      来自第1节。
    • Android
      type: "play_store"
      package_name
      来自第1节。
    • name
      可从标识符推导或询问用户获取。

2c. Get the public API key

2c. 获取公开API密钥

  • Call
    list-public-api-keys
    with the relevant app ID:
    • app_store
      /
      play_store
      if the store-side app exists.
    • Otherwise the
      test_store
      app.
  • The returned key is public and safe to embed in client app code. iOS keys are prefixed
    appl_…
    , Android keys
    goog_…
    , Amazon
    amzn_…
    .
Never use the secret API key in client code. Secret keys are server-side only.
  • 使用相关应用ID调用
    list-public-api-keys
    • 若存在商店端应用,则使用
      app_store
      /
      play_store
    • 否则使用
      test_store
      应用。
  • 返回的密钥为公开密钥,可安全嵌入客户端应用代码中。iOS密钥前缀为
    appl_…
    ,Android密钥前缀为
    goog_…
    ,亚马逊密钥前缀为
    amzn_…
**切勿在客户端代码中使用私密API密钥。**私密密钥仅适用于服务端。

3. App side — install and configure the SDK

3. 应用端——安装并配置SDK

3a. Detect the platform

3a. 检测平台

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.
检查工作目录,按从上到下的顺序选择第一个匹配项:
  1. React Native
    package.json
    包含
    react-native-purchases
    条目,或依赖
    react-native
    → 查看
    platforms/react-native.md
    。若同时依赖
    expo
    ,则标记为Expo项目。
  2. Flutter:项目根目录存在
    pubspec.yaml
    → 查看
    platforms/flutter.md
  3. Kotlin Multiplatform
    build.gradle.kts
    包含
    kotlin { … }
    多平台源码集块,或依赖
    com.revenuecat.purchases:purchases-kmp*
    → 查看
    platforms/kmp.md
  4. Android(原生)
    build.gradle(.kts)
    应用了
    com.android.application
    (且非KMP项目)→ 查看
    platforms/android.md
  5. iOS(原生):项目根目录存在
    Package.swift
    *.xcodeproj
    *.xcworkspace
    Podfile
    → 查看
    platforms/ios.md
若存在多个匹配项(例如Flutter项目中包含
ios/
文件夹),请选择最外层的项目,即负责构建的项目。若仍存在歧义,请询问用户要配置哪个平台。

3b. Shared concepts (all platforms)

3b. 通用概念(所有平台)

  • Public SDK key, not secret key. RevenueCat issues a separate public SDK key per store/platform. iOS apps use an
    appl_…
    key, Android apps use a
    goog_…
    key (Amazon uses
    amzn_…
    ). Server-side secret keys must never appear in client apps.
  • Configure once per app launch. Call
    Purchases.configure(…)
    exactly once, as early as possible (app entry point). Later calls no-op or warn.
  • Anonymous users by default. If you don't pass an
    appUserID
    , RevenueCat creates a stable anonymous ID. Only pass
    appUserID
    if you already have an authenticated user at launch; otherwise call
    logIn(…)
    later (see the
    revenuecat-identify-user
    skill).
  • Enable debug logging during integration. Each platform file shows how. Turn it off for release builds.
  • Keep keys out of source control. Recommend
    .env
    (RN),
    xcconfig
    (iOS),
    local.properties
    /
    gradle.properties
    (Android), or dart-define (Flutter) when the user asks about secret management.
  • **使用公开SDK密钥,而非私密密钥。**RevenueCat为每个商店/平台颁发独立的公开SDK密钥。iOS应用使用
    appl_…
    前缀的密钥,Android应用使用
    goog_…
    前缀的密钥(亚马逊使用
    amzn_…
    前缀)。服务端私密密钥绝不能出现在客户端应用中。
  • **每次应用启动仅配置一次。**仅调用一次
    Purchases.configure(…)
    ,且尽可能早地调用(应用入口点)。后续调用将无操作或发出警告。
  • **默认使用匿名用户。**若未传入
    appUserID
    ,RevenueCat将创建一个稳定的匿名ID。仅当启动时已存在已认证用户时才传入
    appUserID
    ;否则请稍后调用
    logIn(…)
    (详见
    revenuecat-identify-user
    技能)。
  • **集成期间启用调试日志。**各平台文件均说明了启用方式。发布版本需关闭调试日志。
  • **避免密钥进入版本控制。**当用户询问密钥管理时,推荐使用
    .env
    (RN)、
    xcconfig
    (iOS)、
    local.properties
    /
    gradle.properties
    (Android)或dart-define(Flutter)。

3c. Implementation

3c. 实现

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 is self-contained: install command, exact
configure
snippet, and where to place it in the app entry point.
查看与检测结果匹配的平台文件:
  • platforms/ios.md
  • platforms/android.md
  • platforms/kmp.md
  • platforms/flutter.md
  • platforms/react-native.md
每个平台文件均为独立内容:包含安装命令、精确的
configure
代码片段,以及在应用入口点的放置位置。

4. Verify

4. 验证

Do not claim setup is complete until:
  1. The project builds (Xcode build,
    ./gradlew assembleDebug
    ,
    flutter run
    ,
    npx react-native run-ios
    , or the KMP equivalent).
  2. The app launches and the RevenueCat SDK logs a configuration banner in the console / logcat / Metro output (each platform file describes the expected log line).
  3. No authentication errors appear on the first SDK network call. A wrong API key surfaces as an auth error log as soon as the app fetches offerings.
If the user only asked to "install" without running the app, tell them what to look for in the logs when they do run it.
满足以下条件后,方可确认设置完成:
  1. 项目可构建(Xcode构建、
    ./gradlew assembleDebug
    flutter run
    npx react-native run-ios
    或KMP对应的构建命令)。
  2. 应用启动后,RevenueCat SDK在控制台/logcat/Metro输出中打印配置横幅(各平台文件均描述了预期的日志行)。
  3. 首次SDK网络调用未出现认证错误。若API密钥错误,应用获取产品套餐时会立即在日志中显示认证错误。
若用户仅要求“安装”而未运行应用,请告知其运行应用时需在日志中查看的内容。

5. Next steps

5. 后续步骤

5a. Products, entitlements, offerings

5a. 产品、权益、产品套餐

Check whether products, entitlements, and offerings are already set up in the project. If not, offer to help via the
create-revenuecat-project
skill.
检查项目中是否已设置产品、权益和产品套餐。若未设置,可提供
create-revenuecat-project
技能协助完成。

5b. Store-side setup

5b. 商店端设置

iOS (App Store Connect)
  1. In-App Purchase Key (recommended for StoreKit 2) — App Store Connect → Users and Access → Integrations → In-App Purchase. Generate key, download the
    .p8
    file. Note the Key ID and Issuer ID.
  2. Shared Secret (legacy StoreKit 1) — App Store Connect → App → App Information → App-Specific Shared Secret.
  3. If the user provides this information, register it on the RevenueCat side via
    create-app
    /
    update-app
    .
Android (Google Play Console)
  1. Service account credentials — Create a service account in Google Cloud Console. Grant "Service Account User" role. Create a JSON key. In Play Console, grant the service account access with "View financial data" permission.
  2. Real-time Developer Notifications (RTDN) — Set up a Cloud Pub/Sub topic. Configure in Play Console → Monetization setup.
  3. If the user provides this information, register it via
    create-app
    /
    update-app
    .
iOS(App Store Connect)
  1. 内购密钥(推荐用于StoreKit 2)——App Store Connect → 用户与访问 → 集成 → 内购。生成密钥,下载
    .p8
    文件。记录密钥ID和发行者ID。
  2. 共享密钥(旧版StoreKit 1)——App Store Connect → 应用 → 应用信息 → 应用专属共享密钥。
  3. 若用户提供上述信息,请通过
    create-app
    /
    update-app
    在RevenueCat端完成注册。
Android(Google Play Console)
  1. 服务账号凭据——在Google Cloud Console中创建服务账号。授予“服务账号用户”角色。创建JSON密钥。在Play Console中,为该服务账号授予“查看财务数据”权限。
  2. 实时开发者通知(RTDN)——设置Cloud Pub/Sub主题。在Play Console → 变现设置中完成配置。
  3. 若用户提供上述信息,请通过
    create-app
    /
    update-app
    完成注册。

5c. Subsequent skills

5c. 后续技能

Common follow-ups after
integrate-revenuecat
:
  • revenuecat-paywall
    — display a dashboard-configured paywall.
  • revenuecat-purchase-flow
    — implement purchase + restore manually.
  • revenuecat-entitlements-gate
    — gate features behind active entitlements.
  • revenuecat-identify-user
    — wire
    logIn
    /
    logOut
    to the app's auth system.
  • revenuecat-testing-setup
    — set up a sandbox testing channel.
  • revenuecat-troubleshoot
    — diagnose offerings / products / entitlement bugs.
integrate-revenuecat
之后常见的后续操作:
  • revenuecat-paywall
    ——展示控制台配置的付费墙。
  • revenuecat-purchase-flow
    ——手动实现购买+恢复流程。
  • revenuecat-entitlements-gate
    ——通过有效权益限制功能访问。
  • revenuecat-identify-user
    ——将
    logIn
    /
    logOut
    接入应用的认证系统。
  • revenuecat-testing-setup
    ——搭建沙盒测试渠道。
  • revenuecat-troubleshoot
    ——诊断产品套餐/产品/权益相关问题。