概要

StoreKit 2 を使用した自動更新サブスクリプション。月額と年額の2プランを提供。 購入状態は StoreKitService がシングルトンで管理し、Transaction.updates を監視して即時反映。

関連画面

処理フロー(購入)

sequenceDiagram participant U as User participant PV as PaywallView participant SK as StoreKitService participant AS as App Store participant TX as Transaction.updates U->>PV: プラン選択 + 購入 PV->>SK: purchase(product) SK->>AS: Product.purchase() AS->>U: Apple ID認証 U-->>AS: 承認 AS-->>SK: 結果(success/userCancelled/pending) alt success SK->>SK: verification チェック SK->>SK: transaction.finish() SK->>SK: isPremium = true SK->>PV: 完了通知 else userCancelled SK-->>PV: キャンセル else pending SK-->>PV: 「処理中」 end TX-->>SK: バックグラウンド更新通知(自動更新等) SK->>SK: refreshPremiumStatus()

商品定義

プランProduct ID更新
月額com.happyboy1002.RankingStadium.premium.monthly毎月自動更新
年額com.happyboy1002.RankingStadium.premium.yearly毎年自動更新

プレミアム特典

ビジネスルール

外部連携

連携先用途
StoreKit 2Product 取得・purchase / restore / Transaction.updates
App Store Connect商品設定・価格・サブスク期間
users.isPremiumサブスク状態のキャッシュ(Supabase)

エラー処理

発生条件対応
商品未取得ProgressViewで再試行
verification失敗「決済の検証に失敗しました」 + サポート誘導
userCancelledサイレント
pending(保護者承認待ち)「処理中です」表示、Transaction.updates で後続処理
復元時に該当商品なし「復元できる商品がありません」

実装メモ

変更履歴

バージョン日付変更内容
1.02026-05-09初版作成