RevenueCatへの移行、またはRevenueCat SDKのメジャーバージョンアップグレードに対応します。StoreKitやGoogle Play Billingから直接RevenueCatに移行したり、RevenueCat SDKを大きなバージョンアップしたりする場合に使用します。 次のような場合に使用: ユーザーがRevenueCatへの移行、StoreKitからRevenueCatへの切り替え、RevenueCat SDKのアップグレード(v4からv5など)、オブザーバーモード(監視専用の接続方式)への変更、RevenueCatのメジャーバージョンアップグレード、または既存のアプリ内購入機能にRevenueCatを追加したい(iOS、Android、Kotlin Multiplatform、Flutter、React Nativeなど)と述べた場合。
Migrate to RevenueCat from raw StoreKit or Google Play Billing, or upgrade the RevenueCat SDK across a major version. Use when the user says migrate to RevenueCat, switch from StoreKit to RC, upgrade RevenueCat SDK, from v4 to v5, observer mode, RevenueCat major version upgrade, or already have in app purchases and want to add RevenueCat on iOS, Android, Kotlin Multiplatform, Flutter, or React Native.
次のような場合に使用: ユーザーが、すでにアプリ内課金を実装済みのアプリにRevenueCatを導入したい場合、またはRevenueCat SDKをメジャーバージョン間でアップグレードしたい場合。
この2つのパスはいくつかの概念を共有していますが、リスクが異なります。コードに触れる前に、どちらのパスが該当するかを特定してください。
作業ディレクトリを調べ、上から順に最初に一致したものを選択します:
package.json に react-native-purchases のエントリがあるか、react-native が依存関係に含まれている → platforms/react-native.md を参照。expo も依存関係にある場合は、Expoプロジェクトとして記録する。pubspec.yaml が存在する → platforms/flutter.md を参照。build.gradle.kts に kotlin { … } マルチプラットフォームのソースセットブロックが含まれるか、com.revenuecat.purchases:purchases-kmp* に依存している → platforms/kmp.md を参照。build.gradle(.kts) が com.android.application を適用している(かつKMPではない)→ platforms/android.md を参照。Package.swift、*.xcodeproj、*.xcworkspace、または Podfile がある → platforms/ios.md を参照。複数が一致する場合(例: Flutterプロジェクト内の ios/ フォルダ)は、ビルドを管理している最外層のプロジェクトを選択してください。それでも判断できない場合は、ユーザーにどのプラットフォームを設定したいか確認してください。
ユーザーに確認するか、コードベースから推測してください:
両パスを同時に実施することもあります(例: 最新メジャーバージョンでRC導入)。その場合はパスAを先に実行し、その後パスBを実施してください。
Observerモードは、既存の課金コードを書き直すことなくRevenueCatを導入するための重要な手段です。SDKは、既存のStoreKit / Billing コードが処理するトランザクションを監視(observe)し、RevenueCatバックエンドへ送信して検証とサブスクライバー状態の更新を行いますが、トランザクションの開始や完了は行いません。既存の購入UI、レシート検証、トランザクション完了処理はそのまま維持されます。
以下のように設定時に指定してください:
Configuration.Builder で purchasesAreCompletedBy: .myApp と storeKitVersion: .storeKit1(または .storeKit2)を設定する。これらは独立したパラメータであり、単一の関連値ではありません。PurchasesConfiguration.Builder で purchasesAreCompletedBy(PurchasesAreCompletedBy.MY_APP) を指定する。PurchasesConfiguration に const PurchasesAreCompletedByMyApp(storeKitVersion: StoreKitVersion.storeKit2) を渡す。purchasesAreCompletedBy: { type: PURCHASES_ARE_COMPLETED_BY_TYPE.MY_APP, storeKitVersion: STOREKIT_VERSION.STOREKIT_2 } を渡す。デフォルトはRevenueCat側が完了を担当する設定(REVENUECAT / .revenueCat)であり、SDKがフロー全体を管理します。
Observerモードで安定稼働を確認した後は、必要に応じて独自の課金処理を取り除き、purchasesAreCompletedBy の上書きを削除することで、フルRevenueCatモードへ移行できます。
purchasesAreCompletedBy を myApp に設定している場合、RevenueCatはiOSでのトランザクション完了処理もAndroidでの承認処理も行いません。既存のコードが引き続きこれを担当する必要があります。myApp フラグを削除しながら旧来のトランザクション完了処理をそのまま残した場合、トランザクションが二重に承認され、サブスクライバーの状態が不整合になる可能性があります。
完了・承認を担当するのは必ずどちらか一方のみにしてください。どちらにするかを決めたら、もう一方の処理を削除してください。
アプリに独自の認証システムがある場合は、RevenueCatの設定後に Purchases.logIn(existingAppUserID) を呼び出してください。これにより、取り込み時に過去の購入履歴が正しいRevenueCatユーザーに紐付けられます。この手順を省略すると、既存の購入が匿名のRCユーザーとして記録され、後からアプリの実際のユーザーレコードと照合できなくなります。
アプリに認証済みユーザーという概念がない場合のみ、この手順をスキップできます。
メジャーバージョンのアップグレードは、リリースごとに設定の構造を変更し、非推奨APIを削除し、デフォルトの動作を変更します。このスキルはバージョン間の差分を重複して管理しません。SDKリポジトリの正規ソースを参照してください:
*MIGRATION*.md に一致するファイルや migrations/ ディレクトリを検索してください。メジャーバージョンアップには通常、専用のガイドが用意されています。リポジトリのGitHub Releasesページにあるメジャーバージョンのリリースノートにもリンクが記載されています。SDKリポジトリのドキュメントを正規情報として扱ってください。ここにバージョン固有の差分を記載しても、時間の経過とともに陳腐化します。ターゲットプラットフォームの platforms/ 配下のファイルに、参照すべき正確なリポジトリが記載されています。
すべてのプラットフォームで以下の順序で作業してください:
検出結果に対応するプラットフォームファイルを参照してください:
platforms/ios.mdplatforms/android.mdplatforms/kmp.mdplatforms/flutter.mdplatforms/react-native.md各プラットフォームファイルには、そのプラットフォームにおける両方の移行パスが記載されています。
以下がすべて完了するまで移行完了と宣言しないでください:
appUserID でトランザクションが表示される。Use this skill when the user wants to either adopt RevenueCat in an app that already ships in app purchases, or upgrade the RevenueCat SDK across a major version.
These two paths share some concepts but have different risks. Identify which one applies before touching code.
Inspect the working directory and pick the first match, from top to bottom:
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.pubspec.yaml exists at the project root → read platforms/flutter.md.build.gradle.kts contains a kotlin { … } multiplatform source sets block, or depends on com.revenuecat.purchases:purchases-kmp* → read platforms/kmp.md.build.gradle(.kts) applies com.android.application (and is not KMP) → read platforms/android.md.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.
Ask the user (or infer from the codebase):
Both paths can happen at once (e.g. adopt RC today on the latest major version). Run Path A first, then Path B if needed.
Observer mode is the key lever for adopting RevenueCat without rewriting purchase code. The SDK observes transactions that your existing StoreKit / Billing code processes, sends them to the RevenueCat backend for validation, and updates subscriber state, but does not initiate or finish the transactions. Your existing purchase UI, receipt validation, and transaction finishing stay in place.
Set this at configure time:
purchasesAreCompletedBy: .myApp together with storeKitVersion: .storeKit1 (or .storeKit2) on Configuration.Builder. They are separate parameters, not a single associated value.purchasesAreCompletedBy(PurchasesAreCompletedBy.MY_APP) on PurchasesConfiguration.Builder.const PurchasesAreCompletedByMyApp(storeKitVersion: StoreKitVersion.storeKit2) to PurchasesConfiguration.purchasesAreCompletedBy: { type: PURCHASES_ARE_COMPLETED_BY_TYPE.MY_APP, storeKitVersion: STOREKIT_VERSION.STOREKIT_2 } in the configure call.The default is RevenueCat completed (REVENUECAT / .revenueCat), where the SDK owns the full flow.
Once stable in observer mode, you can optionally cut over to full RevenueCat mode later by removing your own purchase plumbing and dropping the purchasesAreCompletedBy override.
When purchasesAreCompletedBy is set to myApp, RevenueCat does not finish transactions on iOS or acknowledge on Android. Your existing code must continue to do that. If you remove the myApp flag while leaving your old transaction finishing code in place, transactions get acknowledged twice and subscriber state can appear inconsistent.
Exactly one side must own finishing / acknowledging. Pick a side and remove the other.
If the app already has its own authentication system, call Purchases.logIn(existingAppUserID) once RevenueCat is configured. This attaches the prior purchase history to the right RevenueCat user on ingestion. Without this step, existing purchases get recorded against an anonymous RC user and cannot be matched to the app's actual user records later.
Only skip this if the app has no notion of authenticated users.
Major version upgrades change configuration shape, drop deprecated APIs, and shift default behavior in ways that move with each release. This skill does not duplicate the per-version diff. Read the canonical sources from the SDK repo:
*MIGRATION*.md or a migrations/ directory. Major bumps usually ship a dedicated guide there. The release notes for the major version on the repo's GitHub releases page typically link to it.Treat the SDK repo's docs as authoritative. Any version-specific diff written here would drift out of date. The platform file under platforms/ for your target lists the exact repo to consult.
Work in this order on every platform:
Read the platform file that matches detection:
platforms/ios.mdplatforms/android.mdplatforms/kmp.mdplatforms/flutter.mdplatforms/react-native.mdEach platform file covers both migration paths for that platform.
Do not declare migration done until:
原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。