コンテンツにジャンプ

iOSサブスクリプショングループを作成

GitHub

サブスクリプション グループは、iOS アプリで複数のサブスクリプション レベルを管理するために不可欠です。サブスクリプション グループがどのように機能するかを理解することは、アップグレード、ダウン グレード、クロス グレード機能を実装するために不可欠です。

サブスクリプション グループとは何か?

サブスクリプション グループとは何か?

サブスクリプション グループとは、ユーザーが選択できる関連するサブスクリプションの集合体です。ユーザーは、グループ内で 1 つのサブスクリプションにのみサブスクライブできます。サブスクリプションを切り替えると、Apple は自動的に移行を処理します。

サブスクリプション グループの重要性

サブスクリプション グループ

サブスクリプション グループにより、以下のことが可能になります。

  • 段階的な価格設定: 基本、プレミアム、そして究極のプランを提供
  • 異なる期間: 月間、年間、そしてライフタイムのオプション
  • アップグレード/ダウングレードロジック: サブスクリプションの変更を自動的に処理
  • シンプルな管理: 関連するサブスクリプションをグループ化

サブスクリプションレベル

サブスクリプションレベル

グループ内で、各サブスクリプションは、値が最も高いレベル1から最も低い値までランク付けされる。このランク付けは、サブスクリプションの変更を分類するために使用される。

サブスクリプショングループ階層

レベル例

レベル1

(最高値) __CAPGO_KEEP_0__

  • プレミアム 年間 ($99.99/年)
  • アクティベート 月額 ($19.99/月)

レベル 2 (中間の価値)

  • スタンダード 年間 ($49.99/年)
  • プレミアム 月額 ($9.99/月)

レベル 3 (最低の価値)

  • ベーシック 年間 ($29.99/年)
  • スタンダード 月額 ($4.99/月)

サブスクリプション 変更の種類

サブスクリプション 変更の種類のセクション

__CAPGO_KEEP_0__が自動的に3つのサブスクリプションのレベルランキングに基づいて、次の3種類の変更を取り扱います:

より高いレベルのサブスクリプションに切り替える(例:レベル2 → レベル1) 動作: 直ちに効果

ユーザーは残りの時間に対して割引を受けます

  • 残りの時間に対する割引を受けます __CAPGO_KEEP_0__が自動的に3つのサブスクリプションのレベルランキングに基づいて、次の3種類の変更を取り扱います:
  • 1. アップグレード セクションのタイトル:「1. アップグレード」 より高いレベルのサブスクリプションに切り替える(例:レベル2 → レベル1)
  • 新規サブスクリプションは即時開始

例:

// User currently has: Standard Monthly (Level 2)
// User upgrades to: Premium Annual (Level 1)
// Result: Immediate access to Premium, refund for unused Standard time

レベルを 下のレベル に下げる(例:レベル1 → レベル2)

動作:

  • 次回更新日以降 ユーザーは現在のサブスクリプションを利用できるまではそのまま残す
  • __CAPGO_KEEP_0__
  • 自動更新で有効期限後すぐに新しいサブスクリプションが開始されます

例:

// User currently has: Premium Annual (Level 1)
// User downgrades to: Standard Monthly (Level 2)
// Result: Premium access continues until annual renewal date, then switches

別のサブスクリプションに切り替える 同じレベルで.

期間が異なる場合

期間が異なる場合 下位グレード

  • 次回の更新日以降に効果が生じます
  • 例:月額プレミアム(レベル1) → 年額プレミアム(レベル1)

同じ期間アップグレード

  • 即時効果
  • 例:プレミアム月額(レベル1) → アンリミテッド月額(レベル1)

サブスクリプション グループの作成

サブスクリプション グループの作成のセクション
  1. サブスクリプションに移動

    App Store Connectでアプリを選択し、 Monetize > サブスクリプション.

  2. グループの作成

    Click + next to “Subscription Groups” to create a new group.

  3. Name the Group

    Choose a descriptive name that reflects the subscriptions it contains:

    • “Premium Access”
    • “Cloud Storage Plans”
    • “Pro Features”
  4. Add Subscriptions

    After creating the group, add individual subscriptions to it. Each subscription will have a level ranking.

  5. Set Level Rankings

    Arrange subscriptions from highest value (1) to lowest value. Consider:

    • Annual plans typically rank higher than monthly
    • 価格帯が高い順に表示される
    • 最高の価格帯

アプリ内で使用

アプリ内で使用

購入プラグインは自動的にサブスクリプショングループのロジックを処理します:

import { NativePurchases, PURCHASE_TYPE } from '@capgo/native-purchases';
// Fetch all subscriptions in a group
const { products } = await NativePurchases.getProducts({
productIdentifiers: ['premium_monthly', 'premium_annual', 'ultimate_monthly'],
productType: PURCHASE_TYPE.SUBS,
});
// Display current subscription using StoreKit transactions
const { purchases } = await NativePurchases.getPurchases({
productType: PURCHASE_TYPE.SUBS,
});
const activeSubs = purchases.filter((purchase) => purchase.isActive);
// Detect pending downgrade/cancellation (StoreKit sets willCancel === true)
const pendingChange = purchases.find((purchase) => purchase.willCancel === true);
if (pendingChange) {
console.log('Subscription will stop auto-renewing on', pendingChange.expirationDate);
}
// Purchase (StoreKit handles upgrades/downgrades automatically)
await NativePurchases.purchaseProduct({
productIdentifier: 'premium_annual',
productType: PURCHASE_TYPE.SUBS,
});
// Listen for StoreKit updates (fires on upgrades/downgrades/refunds)
NativePurchases.addListener('transactionUpdated', (transaction) => {
console.log('Subscription updated:', transaction);
});

サブスクリプションの変更を処理

サブスクリプションの変更を処理

変更のタイプを検出

変更のタイプを検出
import { NativePurchases, PURCHASE_TYPE } from '@capgo/native-purchases';
// Get current subscription info
const { purchases } = await NativePurchases.getPurchases({
productType: PURCHASE_TYPE.SUBS,
});
const currentSubscription = purchases.find(
(purchase) => purchase.subscriptionState === 'subscribed',
);
if (currentSubscription) {
// StoreKit reports if user cancelled auto-renew
if (currentSubscription.willCancel) {
console.log(
`User cancelled. Access remains until ${currentSubscription.expirationDate}`,
);
}
if (currentSubscription.isUpgraded) {
console.log('User recently upgraded to this plan.');
}
}
// Listen for automatic upgrades/downgrades
NativePurchases.addListener('transactionUpdated', (transaction) => {
console.log('Subscription changed!', transaction);
if (transaction.subscriptionState === 'revoked') {
revokeAccess();
} else if (transaction.isActive) {
unlockPremiumFeatures();
}
});

ユーザーとのコミュニケーション

ユーザーとのコミュニケーション

常に変更の動作を明確に伝えます:

アップグレードの場合:

__CAPGO_KEEP_0__

ダウングレードの場合:

__CAPGO_KEEP_0__

クロスグレードの場合:

__CAPGO_KEEP_0__

サーバーモニタリング

サーバーモニタリング

App Store Server Notifications v2を使用するか、StoreKitの変更を反映するために独自の受領検証バックエンドを使用して、データベースにStoreKitの変更をミラーリングします。サーバー通知をリスナーと組み合わせて、クライアントとバックエンドが同期されるようにします。 transactionUpdated For Upgrades: "You'll get immediate access to Premium features. We'll prorate your current subscription." translates to "アップグレードの場合:"__CAPGO_KEEP_0__"です。"

ベスト プラクティス

「ベスト プラクティス」

グループの組織

「グループの組織」
  • 関連するサブスクリプションを同じグループに保管する
  • 無関係な機能を混ぜない (例:ストレージと広告の削除)
  • 異なる機能セットごとに別々のグループを作成する

レベル ランキング ストラテジー

「レベル ランキング ストラテジー」
  • 年間プラン → 月額と同じレベルでも上位
  • 価格が高いプラン → 上位
  • 価値を考慮するだけではなく、価格も考慮する
  • 現在のサブスクリプションを明確に表示する
  • グループ内のすべてのオプションを表示する
  • 即時変更と再契約時変更を区別する
  • プランを簡単に切り替える
  • アップグレードシナリオをすべてテストする
  • ダウングレードシナリオをすべてテストする
  • クロスグレード動作を検証する
  • ウェブフックの発火を確認する
Level 1: Ultimate Monthly ($19.99)
Level 2: Premium Monthly ($9.99)
Level 3: Basic Monthly ($4.99)
  • Basic → Premium: Upgrade (immediate)
  • Premium → Ultimate: Upgrade (immediate)
  • Ultimate → Premium: Downgrade (at renewal)
  • Basic → Ultimate: Upgrade (immediate)
Level 1: Premium Annual ($99.99/year)
Level 2: Premium Monthly ($9.99/month)
  • 月額 → 年額: クロスグレード (更新時)
  • 年額 → 月額: ダウングレード (更新時)

シナリオ 3: マルチレイヤー マルチ期間

「シナリオ 3: マルチレイヤー マルチ期間」のセクション
Level 1: Ultimate Annual ($199/year)
Level 2: Ultimate Monthly ($19.99/month)
Level 3: Premium Annual ($99/year)
Level 4: Premium Monthly ($9.99/month)
Level 5: Basic Annual ($49/year)
Level 6: Basic Monthly ($4.99/month)

この設定では、明確なアップグレード/ダウングレードロジックを維持しながら、最大限の柔軟性を提供します。

グループ内にサブスクリプションが表示されない場合:

  • 正しいグループに割り当てられていることを確認する
  • 少なくとも「提出準備完了」ステータスにあることを確認する
  • 製品IDが正しいことを確認する

アップグレード/ダウングレードの不正動作:

  • レベルランキングの確認 (1 = 最高)
  • サブスクリプションの階層が妥当かどうか確認する
  • レベルが正しく設定されているかどうか確認する

異なるグループの製品:

  • ユーザーは同時に複数のグループにサブスクライブできる
  • これは意図的な動作 - 関連する製品を同じグループに残す

getActiveProducts で複数のサブスクリプションが表示される:

  • サブスクリプションが異なるグループにあるかどうか確認する
  • ユーザーがファミリー シェアリングを通じてサブスクライブしていないかどうか確認する
  • App Store Connect でサブスクリプションの状態を確認する

追加のリソース

追加リソース

詳細は 公式のAppleドキュメントのサブスクリプショングループ.

Create iOS Subscription Groupから続けて

Create iOS Subscription Groupから続けて

Create iOS Subscription Groupを使用している場合 Create iOS Subscription Group ストアの承認と配布を計画するために使用している場合、Create iOS Subscription Groupを Using @capgo/native-purchases Using @capgo/native-purchasesのネイティブ機能 Using @capgo/capacitor-in-app-review Using @capgo/capacitor-in-app-reviewの実装詳細 Using @capgo/capacitor-in-app-review for the native capability in Using @capgo/capacitor-in-app-review, @capgo/capacitor-native-market for the implementation detail in @capgo/capacitor-native-market, and Using @capgo/capacitor-native-market for the native capability in Using @capgo/capacitor-native-market.