まだどこにもないアプリを作る

アプリ開発でつまづいたところなどを中心に記事にして行きます。

SwiftyStoreKitエラーThread 1: Assertion failed: SwiftyStoreKit.completeTransactions() must be called when the app launches.

Thread 1: Assertion failed: SwiftyStoreKit.completeTransactions() must be called when the app launches.

 

AppDelegateに書く文を忘れていませんか?

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

のブロックに

 

        SwiftyStoreKit.completeTransactions(atomically: true) { purchases in

            for purchase in purchases {

                switch purchase.transaction.transactionState {

                case .purchased, .restored:

                    if purchase.needsFinishTransaction {

                        // Deliver content from server, then:

                        SwiftyStoreKit.finishTransaction(purchase.transaction)

                    }

                    // Unlock content

                case .failed, .purchasing, .deferred:

                    break // do nothing

                @unknown default:

                    fatalError()

                }

            }

        }

        

を書きましょう

 

 

そうでなかったらすいません