🔄revenuecat-migrate
- プラグイン
- rc
- ソース
- GitHub で見る ↗
説明
生のStoreKitまたはGoogle Play BillingからRevenueCatへの移行、またはRevenueCat SDKのメジャーバージョンアップグレードを行います。 次のような場合に使用: ユーザーが「RevenueCatへ移行したい」「StoreKitからRevenueCat(RC)に切り替えたい」「RevenueCat SDKをアップグレードしたい」「v4からv5へ移行したい」「オブザーバーモードを使いたい」「RevenueCatのメジャーバージョンアップグレードをしたい」、またはすでにアプリ内購入を実装済みで、iOS・Android・Kotlin Multiplatform・Flutter・React Native向けにRevenueCatを追加したいと述べている場合。
原文を表示
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.
ユースケース
- ✓StoreKitからRevenueCatへ移行するとき
- ✓Google Play BillingからRevenueCatへ移行するとき
- ✓RevenueCat SDKをメジャーバージョンアップグレードするとき
- ✓既存アプリ内購入実装にRevenueCatを追加するとき
本文(日本語訳)
revenuecat-migrate: RevenueCatへの移行またはSDKのアップグレード
次のような場合に使用: ユーザーが、すでにアプリ内課金を実装済みのアプリにRevenueCatを導入したい場合、またはRevenueCat SDKをメジャーバージョン間でアップグレードしたい場合。
この2つのパスはいくつかの概念を共有していますが、リスクが異なります。コードに触れる前に、どちらのパスが該当するかを特定してください。
1. プラットフォームの検出
作業ディレクトリを調べ、上から順に最初に一致したものを選択します:
- 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)がcom.android.applicationを適用している(かつKMPではない)→platforms/android.mdを参照。 - iOS (ネイティブ): プロジェクトルートに
Package.swift、*.xcodeproj、*.xcworkspace、またはPodfileがある →platforms/ios.mdを参照。
複数が一致する場合(例: Flutterプロジェクト内の ios/ フォルダ)は、ビルドを管理している最外層のプロジェクトを選択してください。それでも判断できない場合は、ユーザーにどのプラットフォームを設定したいか確認してください。
2. 移行パスの特定
ユーザーに確認するか、コードベースから推測してください:
- パスA: 新規導入。 アプリがすでにStoreKitまたはGoogle Play Billingを直接利用したアプリ内課金を実装済みであり、その上にRevenueCatを追加する。
- パスB: バージョンアップグレード。 アプリがすでにRevenueCatを使用しており、あるメジャーバージョンから次のバージョンへ移行したい(例: v4からv5、v7からv8)。
両パスを同時に実施することもあります(例: 最新メジャーバージョンでRC導入)。その場合はパスAを先に実行し、その後パスBを実施してください。
3. 共通の概念
Observerモード(パスA)
Observerモードは、既存の課金コードを書き直すことなくRevenueCatを導入するための重要な手段です。SDKは、既存のStoreKit / Billing コードが処理するトランザクションを監視(observe)し、RevenueCatバックエンドへ送信して検証とサブスクライバー状態の更新を行いますが、トランザクションの開始や完了は行いません。既存の購入UI、レシート検証、トランザクション完了処理はそのまま維持されます。
以下のように設定時に指定してください:
- iOS:
Configuration.BuilderでpurchasesAreCompletedBy: .myAppとstoreKitVersion: .storeKit1(または.storeKit2)を設定する。これらは独立したパラメータであり、単一の関連値ではありません。 - Android:
PurchasesConfiguration.BuilderでpurchasesAreCompletedBy(PurchasesAreCompletedBy.MY_APP)を指定する。 - Flutter:
PurchasesConfigurationにconst PurchasesAreCompletedByMyApp(storeKitVersion: StoreKitVersion.storeKit2)を渡す。 - React Native: configure呼び出しで
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 フラグを削除しながら旧来のトランザクション完了処理をそのまま残した場合、トランザクションが二重に承認され、サブスクライバーの状態が不整合になる可能性があります。
完了・承認を担当するのは必ずどちらか一方のみにしてください。どちらにするかを決めたら、もう一方の処理を削除してください。
ユーザーの継続性(パスA)
アプリに独自の認証システムがある場合は、RevenueCatの設定後に Purchases.logIn(existingAppUserID) を呼び出してください。これにより、取り込み時に過去の購入履歴が正しいRevenueCatユーザーに紐付けられます。この手順を省略すると、既存の購入が匿名のRCユーザーとして記録され、後からアプリの実際のユーザーレコードと照合できなくなります。
アプリに認証済みユーザーという概念がない場合のみ、この手順をスキップできます。
メジャーバージョンアップは必須フィールドを変更する(パスB)
メジャーバージョンのアップグレードは、リリースごとに設定の構造を変更し、非推奨APIを削除し、デフォルトの動作を変更します。このスキルはバージョン間の差分を重複して管理しません。SDKリポジトリの正規ソースを参照してください:
- CHANGELOG: GitHub上の該当SDKリポジトリ内。インストール済みバージョンからターゲットバージョンまでのエントリを順に確認してください。
- 移行ガイド: SDKリポジトリで
*MIGRATION*.mdに一致するファイルやmigrations/ディレクトリを検索してください。メジャーバージョンアップには通常、専用のガイドが用意されています。リポジトリのGitHub Releasesページにあるメジャーバージョンのリリースノートにもリンクが記載されています。 - リリースノート: リポジトリのGitHub Releasesページに掲載されている各メジャーバージョンのリリースノートには、破壊的変更がまとめられています。
SDKリポジトリのドキュメントを正規情報として扱ってください。ここにバージョン固有の差分を記載しても、時間の経過とともに陳腐化します。ターゲットプラットフォームの platforms/ 配下のファイルに、参照すべき正確なリポジトリが記載されています。
計画してから移行する
すべてのプラットフォームで以下の順序で作業してください:
- ブランチでSDKを新しいメジャーバージョンに更新する。
- CHANGELOGの非推奨・削除の記録を参照しながらコンパイルエラーを修正する。
- 初回起動時のSDKログを参照しながら実行時の動作を修正する。
- マージ前に既存のテストスイートと手動でのサンドボックスシナリオを実行する。
4. 実装
検出結果に対応するプラットフォームファイルを参照してください:
platforms/ios.mdplatforms/android.mdplatforms/kmp.mdplatforms/flutter.mdplatforms/react-native.md
各プラットフォームファイルには、そのプラットフォームにおける両方の移行パスが記載されています。
5. 検証
以下がすべて完了するまで移行完了と宣言しないでください:
- アプリが新しいSDKバージョンでビルドでき、対象の非推奨APIに関する警告が出ていない。
- サンドボックスでの購入が成功し、RevenueCatダッシュボードのSandboxビューに、期待通りの
appUserIDでトランザクションが表示される。 - 移行前から存在するサブスクライバーがアプリを開いたとき、エンタイトルメントの状態が正しい。パスAの場合はObserverモードによる取り込みが機能したことの証明となり、パスBの場合はバージョンアップによって状態が失われていないことの証明となる。
- リリース前にデバッグログレベルの上書き設定を削除している。
原文(English)を表示
revenuecat-migrate: migrate to RevenueCat or upgrade the SDK
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.
1. Detect the platform
Inspect the working directory and pick the first match, from top to bottom:
- React Native:
package.jsonhas areact-native-purchasesentry, orreact-nativeas a dependency → readplatforms/react-native.md. Ifexpois also a dependency, note it as an Expo project. - Flutter:
pubspec.yamlexists at the project root → readplatforms/flutter.md. - Kotlin Multiplatform:
build.gradle.ktscontains akotlin { … }multiplatform source sets block, or depends oncom.revenuecat.purchases:purchases-kmp*→ readplatforms/kmp.md. - Android (native):
build.gradle(.kts)appliescom.android.application(and is not KMP) → readplatforms/android.md. - iOS (native):
Package.swift,*.xcodeproj,*.xcworkspace, orPodfileat the project root → readplatforms/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. Identify the migration path
Ask the user (or infer from the codebase):
- Path A: adoption. The app already has working in app purchases implemented directly against StoreKit or Google Play Billing. RevenueCat is being added on top.
- Path B: version upgrade. The app already uses RevenueCat, and the user wants to bump from one major version to the next (e.g. v4 to v5, v7 to v8).
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.
3. Shared concepts
Observer mode (Path A)
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:
- iOS: set
purchasesAreCompletedBy: .myApptogether withstoreKitVersion: .storeKit1(or.storeKit2) onConfiguration.Builder. They are separate parameters, not a single associated value. - Android:
purchasesAreCompletedBy(PurchasesAreCompletedBy.MY_APP)onPurchasesConfiguration.Builder. - Flutter: pass
const PurchasesAreCompletedByMyApp(storeKitVersion: StoreKitVersion.storeKit2)toPurchasesConfiguration. - React Native: pass
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.
Do not double process transactions
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.
User continuity (Path A)
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.
Version bumps change required fields (Path B)
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:
- CHANGELOG: in the relevant SDK repo on GitHub. Walk entries from your installed version up to the target.
- Migration guides: search the SDK repo for files matching
*MIGRATION*.mdor amigrations/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. - Release notes: each major version's release notes on the repo's GitHub releases page summarize the breaking changes.
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.
Plan then migrate
Work in this order on every platform:
- Bump the SDK to the new major version in a branch.
- Fix compile errors using the CHANGELOG deprecations and removals as a guide.
- Fix runtime behavior by reading the SDK logs on first launch.
- Run the existing test suite and manual sandbox scenarios before merging.
4. Implementation
Read the platform file that matches detection:
platforms/ios.mdplatforms/android.mdplatforms/kmp.mdplatforms/flutter.mdplatforms/react-native.md
Each platform file covers both migration paths for that platform.
5. Verify
Do not declare migration done until:
- The app builds on the new SDK version with no warnings from deprecated APIs you care about.
- A sandbox purchase succeeds and the transaction shows up on the RevenueCat dashboard Sandbox view with the expected appUserID.
- An existing subscriber from before the migration opens the app, and their entitlement state is correct. For Path A this proves the observer mode ingest worked. For Path B this proves the version bump did not drop state.
- You have removed the debug log level override before shipping.
原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。