概要

StoreKit 2 を使用したサブスクリプション課金。月額・年額の2プラン。Trial(無料試用)対応、Transaction.updates でリアルタイム反映。

関連画面

提供商品

プランProduct ID
月額com.happyboy1002.WorkoutDiary.premium.monthly.v2
年額com.happyboy1002.WorkoutDiary.premium.yearly

StoreManager API

@Observable @MainActor
final class StoreManager {
    var products: [Product]
    var purchasedProductIDs: Set<String>
    var isPremium: Bool
    var trialRemainingDays: Int?

    func loadProducts() async
    func purchase(_ product: Product) async throws
    func restorePurchases() async throws
    func startTransactionListener()
    func checkVerified<T>(_ result: VerificationResult<T>) throws -> T
}

Trial(無料試用)

ビジネスルール

外部連携

連携先用途
StoreKit 2Product 取得・purchase / Transaction.updates
App Store Connect商品設定・価格

エラー処理

発生条件対応
verification失敗「決済の検証に失敗しました」
userCancelledサイレント
pending「処理中です」+ Transaction.updates 待機

変更履歴

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