From 3496422585ff66e0709b7fb773fa2551e10fe880 Mon Sep 17 00:00:00 2001 From: louisehsu Date: Tue, 10 Mar 2026 16:17:52 -0700 Subject: [PATCH 1/6] init --- .../InAppPurchasePlugin.swift | 3 +- .../InAppPurchasePlugin+StoreKit2.swift | 15 + .../StoreKit2/StoreKit2Messages.g.swift | 185 ++--- .../ios/Flutter/AppFrameworkInfo.plist | 2 - .../ios/Runner.xcodeproj/project.pbxproj | 23 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 + .../example/ios/Runner/AppDelegate.h | 2 +- .../example/ios/Runner/AppDelegate.m | 5 +- .../example/ios/Runner/Info.plist | 21 + .../example/lib/main.dart | 24 + .../macos/Runner.xcodeproj/project.pbxproj | 38 +- .../example/pubspec.yaml | 4 +- .../in_app_purchase_storekit_platform.dart | 1 + ...p_purchase_storekit_platform_addition.dart | 4 + .../lib/src/sk2_pigeon.g.dart | 667 ++++++++---------- .../sk2_appstore_wrapper.dart | 5 + .../pigeons/sk2_pigeon.dart | 3 + 17 files changed, 461 insertions(+), 543 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/InAppPurchasePlugin.swift b/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/InAppPurchasePlugin.swift index 249aae616094..175a573dbc80 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/InAppPurchasePlugin.swift +++ b/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/InAppPurchasePlugin.swift @@ -15,7 +15,7 @@ import StoreKit import FlutterMacOS #endif -public class InAppPurchasePlugin: NSObject, FlutterPlugin, FIAInAppPurchaseAPI { +public class InAppPurchasePlugin: NSObject, FlutterPlugin, FIAInAppPurchaseAPI, FlutterSceneLifeCycleDelegate { private let receiptManager: FIAPReceiptManager private var productsCache: NSMutableDictionary = [:] private var paymentQueueDelegateCallbackChannel: FlutterMethodChannel? @@ -60,6 +60,7 @@ public class InAppPurchasePlugin: NSObject, FlutterPlugin, FIAInAppPurchaseAPI { SetUpFIAInAppPurchaseAPI(messenger, instance) if #available(iOS 15.0, macOS 12.0, *) { InAppPurchase2APISetup.setUp(binaryMessenger: messenger, api: instance) + registrar.addSceneDelegate(instance) } } diff --git a/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2/InAppPurchasePlugin+StoreKit2.swift b/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2/InAppPurchasePlugin+StoreKit2.swift index 3b4ceac802c8..c1f71e696766 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2/InAppPurchasePlugin+StoreKit2.swift +++ b/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2/InAppPurchasePlugin+StoreKit2.swift @@ -321,6 +321,21 @@ extension InAppPurchasePlugin: InAppPurchase2API { } } + func presentOfferCodeRedeemSheet(completion: @escaping (Result) -> Void) { + if #available(iOS 16.0, *) { + let windowScene = self.registrar?.viewController?.view.window?.windowScene + + Task { + do { + try await AppStore.presentOfferCodeRedeemSheet(in: windowScene!) + completion(.success(())) + } catch { + completion(.failure(error)) + } + } + } + } + /// Wrapper method around StoreKit2's sync() method /// https://developer.apple.com/documentation/storekit/appstore/sync() /// When called, a system prompt will ask users to enter their authentication details diff --git a/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2/StoreKit2Messages.g.swift b/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2/StoreKit2Messages.g.swift index 81691c5e071e..7ebba1df5a2c 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2/StoreKit2Messages.g.swift +++ b/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2/StoreKit2Messages.g.swift @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v26.1.5), do not edit directly. +// Autogenerated from Pigeon (v26.1.10), do not edit directly. // See also: https://pub.dev/packages/pigeon import Foundation @@ -59,9 +59,7 @@ private func wrapError(_ error: Any) -> [Any?] { } private func createConnectionError(withChannelName channelName: String) -> PigeonError { - return PigeonError( - code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.", - details: "") + return PigeonError(code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.", details: "") } private func isNullish(_ value: Any?) -> Bool { @@ -116,12 +114,12 @@ func deepEqualsStoreKit2Messages(_ lhs: Any?, _ rhs: Any?) -> Bool { func deepHashStoreKit2Messages(value: Any?, hasher: inout Hasher) { if let valueList = value as? [AnyHashable] { - for item in valueList { deepHashStoreKit2Messages(value: item, hasher: &hasher) } - return + for item in valueList { deepHashStoreKit2Messages(value: item, hasher: &hasher) } + return } if let valueDict = value as? [AnyHashable: AnyHashable] { - for key in valueDict.keys { + for key in valueDict.keys { hasher.combine(key) deepHashStoreKit2Messages(value: valueDict[key]!, hasher: &hasher) } @@ -135,6 +133,8 @@ func deepHashStoreKit2Messages(value: Any?, hasher: inout Hasher) { return hasher.combine(String(describing: value)) } + + enum SK2ProductTypeMessage: Int { /// A consumable in-app purchase. case consumable = 0 @@ -194,6 +194,7 @@ struct SK2SubscriptionOfferMessage: Hashable { var periodCount: Int64 var paymentMode: SK2SubscriptionOfferPaymentModeMessage + // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2SubscriptionOfferMessage? { let id: String? = nilOrValue(pigeonVar_list[0]) @@ -223,8 +224,7 @@ struct SK2SubscriptionOfferMessage: Hashable { ] } static func == (lhs: SK2SubscriptionOfferMessage, rhs: SK2SubscriptionOfferMessage) -> Bool { - return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) - } + return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) } func hash(into hasher: inout Hasher) { deepHashStoreKit2Messages(value: toList(), hasher: &hasher) } @@ -237,6 +237,7 @@ struct SK2SubscriptionPeriodMessage: Hashable { /// The unit of time that this period represents. var unit: SK2SubscriptionPeriodUnitMessage + // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2SubscriptionPeriodMessage? { let value = pigeonVar_list[0] as! Int64 @@ -254,8 +255,7 @@ struct SK2SubscriptionPeriodMessage: Hashable { ] } static func == (lhs: SK2SubscriptionPeriodMessage, rhs: SK2SubscriptionPeriodMessage) -> Bool { - return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) - } + return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) } func hash(into hasher: inout Hasher) { deepHashStoreKit2Messages(value: toList(), hasher: &hasher) } @@ -270,6 +270,7 @@ struct SK2SubscriptionInfoMessage: Hashable { /// The duration that this subscription lasts before auto-renewing. var subscriptionPeriod: SK2SubscriptionPeriodMessage + // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2SubscriptionInfoMessage? { let promotionalOffers = pigeonVar_list[0] as! [SK2SubscriptionOfferMessage] @@ -290,8 +291,7 @@ struct SK2SubscriptionInfoMessage: Hashable { ] } static func == (lhs: SK2SubscriptionInfoMessage, rhs: SK2SubscriptionInfoMessage) -> Bool { - return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) - } + return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) } func hash(into hasher: inout Hasher) { deepHashStoreKit2Messages(value: toList(), hasher: &hasher) } @@ -319,6 +319,7 @@ struct SK2ProductMessage: Hashable { /// The currency and locale information for this product var priceLocale: SK2PriceLocaleMessage + // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2ProductMessage? { let id = pigeonVar_list[0] as! String @@ -354,8 +355,7 @@ struct SK2ProductMessage: Hashable { ] } static func == (lhs: SK2ProductMessage, rhs: SK2ProductMessage) -> Bool { - return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) - } + return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) } func hash(into hasher: inout Hasher) { deepHashStoreKit2Messages(value: toList(), hasher: &hasher) } @@ -366,6 +366,7 @@ struct SK2PriceLocaleMessage: Hashable { var currencyCode: String var currencySymbol: String + // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2PriceLocaleMessage? { let currencyCode = pigeonVar_list[0] as! String @@ -383,8 +384,7 @@ struct SK2PriceLocaleMessage: Hashable { ] } static func == (lhs: SK2PriceLocaleMessage, rhs: SK2PriceLocaleMessage) -> Bool { - return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) - } + return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) } func hash(into hasher: inout Hasher) { deepHashStoreKit2Messages(value: toList(), hasher: &hasher) } @@ -400,6 +400,7 @@ struct SK2SubscriptionOfferSignatureMessage: Hashable { var timestamp: Int64 var signature: String + // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2SubscriptionOfferSignatureMessage? { let keyID = pigeonVar_list[0] as! String @@ -422,11 +423,8 @@ struct SK2SubscriptionOfferSignatureMessage: Hashable { signature, ] } - static func == ( - lhs: SK2SubscriptionOfferSignatureMessage, rhs: SK2SubscriptionOfferSignatureMessage - ) -> Bool { - return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) - } + static func == (lhs: SK2SubscriptionOfferSignatureMessage, rhs: SK2SubscriptionOfferSignatureMessage) -> Bool { + return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) } func hash(into hasher: inout Hasher) { deepHashStoreKit2Messages(value: toList(), hasher: &hasher) } @@ -437,6 +435,7 @@ struct SK2SubscriptionOfferPurchaseMessage: Hashable { var promotionalOfferId: String var promotionalOfferSignature: SK2SubscriptionOfferSignatureMessage + // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2SubscriptionOfferPurchaseMessage? { let promotionalOfferId = pigeonVar_list[0] as! String @@ -453,11 +452,8 @@ struct SK2SubscriptionOfferPurchaseMessage: Hashable { promotionalOfferSignature, ] } - static func == ( - lhs: SK2SubscriptionOfferPurchaseMessage, rhs: SK2SubscriptionOfferPurchaseMessage - ) -> Bool { - return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) - } + static func == (lhs: SK2SubscriptionOfferPurchaseMessage, rhs: SK2SubscriptionOfferPurchaseMessage) -> Bool { + return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) } func hash(into hasher: inout Hasher) { deepHashStoreKit2Messages(value: toList(), hasher: &hasher) } @@ -470,6 +466,7 @@ struct SK2ProductPurchaseOptionsMessage: Hashable { var promotionalOffer: SK2SubscriptionOfferPurchaseMessage? = nil var winBackOfferId: String? = nil + // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2ProductPurchaseOptionsMessage? { let appAccountToken: String? = nilOrValue(pigeonVar_list[0]) @@ -492,11 +489,8 @@ struct SK2ProductPurchaseOptionsMessage: Hashable { winBackOfferId, ] } - static func == (lhs: SK2ProductPurchaseOptionsMessage, rhs: SK2ProductPurchaseOptionsMessage) - -> Bool - { - return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) - } + static func == (lhs: SK2ProductPurchaseOptionsMessage, rhs: SK2ProductPurchaseOptionsMessage) -> Bool { + return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) } func hash(into hasher: inout Hasher) { deepHashStoreKit2Messages(value: toList(), hasher: &hasher) } @@ -518,6 +512,7 @@ struct SK2TransactionMessage: Hashable { /// Set by native side to communicate the result state to Dart layer. var status: SK2PurchaseStatusMessage + // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2TransactionMessage? { let id = pigeonVar_list[0] as! Int64 @@ -562,8 +557,7 @@ struct SK2TransactionMessage: Hashable { ] } static func == (lhs: SK2TransactionMessage, rhs: SK2TransactionMessage) -> Bool { - return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) - } + return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) } func hash(into hasher: inout Hasher) { deepHashStoreKit2Messages(value: toList(), hasher: &hasher) } @@ -575,6 +569,7 @@ struct SK2ErrorMessage: Hashable { var domain: String var userInfo: [String: Any]? = nil + // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2ErrorMessage? { let code = pigeonVar_list[0] as! Int64 @@ -595,8 +590,7 @@ struct SK2ErrorMessage: Hashable { ] } static func == (lhs: SK2ErrorMessage, rhs: SK2ErrorMessage) -> Bool { - return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) - } + return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) } func hash(into hasher: inout Hasher) { deepHashStoreKit2Messages(value: toList(), hasher: &hasher) } @@ -734,46 +728,35 @@ private class StoreKit2MessagesPigeonCodecReaderWriter: FlutterStandardReaderWri } class StoreKit2MessagesPigeonCodec: FlutterStandardMessageCodec, @unchecked Sendable { - static let shared = StoreKit2MessagesPigeonCodec( - readerWriter: StoreKit2MessagesPigeonCodecReaderWriter()) + static let shared = StoreKit2MessagesPigeonCodec(readerWriter: StoreKit2MessagesPigeonCodecReaderWriter()) } + /// Generated protocol from Pigeon that represents a handler of messages from Flutter. protocol InAppPurchase2API { func canMakePayments() throws -> Bool - func products( - identifiers: [String], completion: @escaping (Result<[SK2ProductMessage], Error>) -> Void) - func purchase( - id: String, options: SK2ProductPurchaseOptionsMessage?, - completion: @escaping (Result) -> Void) - func isWinBackOfferEligible( - productId: String, offerId: String, completion: @escaping (Result) -> Void) - func isIntroductoryOfferEligible( - productId: String, completion: @escaping (Result) -> Void) + func products(identifiers: [String], completion: @escaping (Result<[SK2ProductMessage], Error>) -> Void) + func purchase(id: String, options: SK2ProductPurchaseOptionsMessage?, completion: @escaping (Result) -> Void) + func isWinBackOfferEligible(productId: String, offerId: String, completion: @escaping (Result) -> Void) + func isIntroductoryOfferEligible(productId: String, completion: @escaping (Result) -> Void) func transactions(completion: @escaping (Result<[SK2TransactionMessage], Error>) -> Void) - func unfinishedTransactions( - completion: @escaping (Result<[SK2TransactionMessage], Error>) -> Void) + func unfinishedTransactions(completion: @escaping (Result<[SK2TransactionMessage], Error>) -> Void) func finish(id: Int64, completion: @escaping (Result) -> Void) func startListeningToTransactions() throws func stopListeningToTransactions() throws func restorePurchases(completion: @escaping (Result) -> Void) func countryCode(completion: @escaping (Result) -> Void) func sync(completion: @escaping (Result) -> Void) + func presentOfferCodeRedeemSheet(completion: @escaping (Result) -> Void) } /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. class InAppPurchase2APISetup { static var codec: FlutterStandardMessageCodec { StoreKit2MessagesPigeonCodec.shared } /// Sets up an instance of `InAppPurchase2API` to handle messages through the `binaryMessenger`. - static func setUp( - binaryMessenger: FlutterBinaryMessenger, api: InAppPurchase2API?, - messageChannelSuffix: String = "" - ) { + static func setUp(binaryMessenger: FlutterBinaryMessenger, api: InAppPurchase2API?, messageChannelSuffix: String = "") { let channelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : "" - let canMakePaymentsChannel = FlutterBasicMessageChannel( - name: - "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.canMakePayments\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let canMakePaymentsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.canMakePayments\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { canMakePaymentsChannel.setMessageHandler { _, reply in do { @@ -786,10 +769,7 @@ class InAppPurchase2APISetup { } else { canMakePaymentsChannel.setMessageHandler(nil) } - let productsChannel = FlutterBasicMessageChannel( - name: - "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.products\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let productsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.products\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { productsChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -806,10 +786,7 @@ class InAppPurchase2APISetup { } else { productsChannel.setMessageHandler(nil) } - let purchaseChannel = FlutterBasicMessageChannel( - name: - "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.purchase\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let purchaseChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.purchase\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { purchaseChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -827,10 +804,7 @@ class InAppPurchase2APISetup { } else { purchaseChannel.setMessageHandler(nil) } - let isWinBackOfferEligibleChannel = FlutterBasicMessageChannel( - name: - "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.isWinBackOfferEligible\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let isWinBackOfferEligibleChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.isWinBackOfferEligible\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { isWinBackOfferEligibleChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -848,10 +822,7 @@ class InAppPurchase2APISetup { } else { isWinBackOfferEligibleChannel.setMessageHandler(nil) } - let isIntroductoryOfferEligibleChannel = FlutterBasicMessageChannel( - name: - "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.isIntroductoryOfferEligible\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let isIntroductoryOfferEligibleChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.isIntroductoryOfferEligible\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { isIntroductoryOfferEligibleChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -868,10 +839,7 @@ class InAppPurchase2APISetup { } else { isIntroductoryOfferEligibleChannel.setMessageHandler(nil) } - let transactionsChannel = FlutterBasicMessageChannel( - name: - "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.transactions\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let transactionsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.transactions\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { transactionsChannel.setMessageHandler { _, reply in api.transactions { result in @@ -886,10 +854,7 @@ class InAppPurchase2APISetup { } else { transactionsChannel.setMessageHandler(nil) } - let unfinishedTransactionsChannel = FlutterBasicMessageChannel( - name: - "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.unfinishedTransactions\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let unfinishedTransactionsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.unfinishedTransactions\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { unfinishedTransactionsChannel.setMessageHandler { _, reply in api.unfinishedTransactions { result in @@ -904,9 +869,7 @@ class InAppPurchase2APISetup { } else { unfinishedTransactionsChannel.setMessageHandler(nil) } - let finishChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.finish\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let finishChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.finish\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { finishChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -923,10 +886,7 @@ class InAppPurchase2APISetup { } else { finishChannel.setMessageHandler(nil) } - let startListeningToTransactionsChannel = FlutterBasicMessageChannel( - name: - "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.startListeningToTransactions\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let startListeningToTransactionsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.startListeningToTransactions\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { startListeningToTransactionsChannel.setMessageHandler { _, reply in do { @@ -939,10 +899,7 @@ class InAppPurchase2APISetup { } else { startListeningToTransactionsChannel.setMessageHandler(nil) } - let stopListeningToTransactionsChannel = FlutterBasicMessageChannel( - name: - "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.stopListeningToTransactions\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let stopListeningToTransactionsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.stopListeningToTransactions\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { stopListeningToTransactionsChannel.setMessageHandler { _, reply in do { @@ -955,10 +912,7 @@ class InAppPurchase2APISetup { } else { stopListeningToTransactionsChannel.setMessageHandler(nil) } - let restorePurchasesChannel = FlutterBasicMessageChannel( - name: - "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.restorePurchases\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let restorePurchasesChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.restorePurchases\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { restorePurchasesChannel.setMessageHandler { _, reply in api.restorePurchases { result in @@ -973,10 +927,7 @@ class InAppPurchase2APISetup { } else { restorePurchasesChannel.setMessageHandler(nil) } - let countryCodeChannel = FlutterBasicMessageChannel( - name: - "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.countryCode\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let countryCodeChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.countryCode\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { countryCodeChannel.setMessageHandler { _, reply in api.countryCode { result in @@ -991,9 +942,7 @@ class InAppPurchase2APISetup { } else { countryCodeChannel.setMessageHandler(nil) } - let syncChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.sync\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let syncChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.sync\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { syncChannel.setMessageHandler { _, reply in api.sync { result in @@ -1008,13 +957,26 @@ class InAppPurchase2APISetup { } else { syncChannel.setMessageHandler(nil) } + let presentOfferCodeRedeemSheetChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.presentOfferCodeRedeemSheet\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + presentOfferCodeRedeemSheetChannel.setMessageHandler { _, reply in + api.presentOfferCodeRedeemSheet { result in + switch result { + case .success: + reply(wrapResult(nil)) + case .failure(let error): + reply(wrapError(error)) + } + } + } + } else { + presentOfferCodeRedeemSheetChannel.setMessageHandler(nil) + } } } /// Generated protocol from Pigeon that represents Flutter messages that can be called from Swift. protocol InAppPurchase2CallbackAPIProtocol { - func onTransactionsUpdated( - newTransactions newTransactionsArg: [SK2TransactionMessage], - completion: @escaping (Result) -> Void) + func onTransactionsUpdated(newTransactions newTransactionsArg: [SK2TransactionMessage], completion: @escaping (Result) -> Void) } class InAppPurchase2CallbackAPI: InAppPurchase2CallbackAPIProtocol { private let binaryMessenger: FlutterBinaryMessenger @@ -1026,14 +988,9 @@ class InAppPurchase2CallbackAPI: InAppPurchase2CallbackAPIProtocol { var codec: StoreKit2MessagesPigeonCodec { return StoreKit2MessagesPigeonCodec.shared } - func onTransactionsUpdated( - newTransactions newTransactionsArg: [SK2TransactionMessage], - completion: @escaping (Result) -> Void - ) { - let channelName: String = - "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2CallbackAPI.onTransactionsUpdated\(messageChannelSuffix)" - let channel = FlutterBasicMessageChannel( - name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func onTransactionsUpdated(newTransactions newTransactionsArg: [SK2TransactionMessage], completion: @escaping (Result) -> Void) { + let channelName: String = "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2CallbackAPI.onTransactionsUpdated\(messageChannelSuffix)" + let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([newTransactionsArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { completion(.failure(createConnectionError(withChannelName: channelName))) diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Flutter/AppFrameworkInfo.plist b/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Flutter/AppFrameworkInfo.plist index 1dc6cf7652ba..391a902b2beb 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Flutter/AppFrameworkInfo.plist +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Flutter/AppFrameworkInfo.plist @@ -20,7 +20,5 @@ ???? CFBundleVersion 1.0 - MinimumOSVersion - 13.0 diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner.xcodeproj/project.pbxproj b/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner.xcodeproj/project.pbxproj index 085fb7654bde..c0a2696fa1d0 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner.xcodeproj/project.pbxproj @@ -60,6 +60,7 @@ 21CE6E615CF661FC0E18FB0A /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 6458340B2CE3497379F6B389 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; + 78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterGeneratedPluginSwiftPackage; path = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; sourceTree = ""; }; 7AB7758EFACBE3E1E7BDE0C6 /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; @@ -135,6 +136,7 @@ 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( + 78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */, 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 9740EEB21CF90195004384FC /* Debug.xcconfig */, 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, @@ -233,7 +235,6 @@ 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - 325E900B3895C722B0E09318 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -337,26 +338,6 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 325E900B3895C722B0E09318 /* [CP] Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh", - "${PODS_CONFIGURATION_BUILD_DIR}/in_app_purchase_storekit/in_app_purchase_storekit_privacy.bundle", - "${PODS_CONFIGURATION_BUILD_DIR}/shared_preferences_foundation/shared_preferences_foundation_privacy.bundle", - ); - name = "[CP] Copy Pods Resources"; - outputPaths = ( - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/in_app_purchase_storekit_privacy.bundle", - "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/shared_preferences_foundation_privacy.bundle", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; 39A4BCA317070A14A6C5C70F /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index a65139025b00..d9fb4e2662c8 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -44,6 +44,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit" shouldUseLaunchSchemeArgsEnv = "YES" codeCoverageEnabled = "YES"> @@ -73,6 +74,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner/AppDelegate.h b/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner/AppDelegate.h index 721cca1e11bb..9b771e7f7408 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner/AppDelegate.h +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner/AppDelegate.h @@ -5,6 +5,6 @@ #import #import -@interface AppDelegate : FlutterAppDelegate +@interface AppDelegate : FlutterAppDelegate @end diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner/AppDelegate.m b/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner/AppDelegate.m index fff9545d5055..b416e30b601b 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner/AppDelegate.m +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner/AppDelegate.m @@ -9,9 +9,12 @@ @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - [GeneratedPluginRegistrant registerWithRegistry:self]; // Override point for customization after application launch. return [super application:application didFinishLaunchingWithOptions:launchOptions]; } +- (void)didInitializeImplicitFlutterEngine:(NSObject*)engineBridge { + [GeneratedPluginRegistrant registerWithRegistry:engineBridge.pluginRegistry]; +} + @end diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner/Info.plist b/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner/Info.plist index 5304b6ed1f84..4975762308f5 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner/Info.plist +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner/Info.plist @@ -43,5 +43,26 @@ UIApplicationSupportsIndirectInputEvents + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneClassName + UIWindowScene + UISceneDelegateClassName + FlutterSceneDelegate + UISceneConfigurationName + flutter + UISceneStoryboardFile + Main + + + + diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/lib/main.dart b/packages/in_app_purchase/in_app_purchase_storekit/example/lib/main.dart index 3a0e5a449ac9..99c09e888790 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/lib/main.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/lib/main.dart @@ -148,6 +148,7 @@ class _MyAppState extends State<_MyApp> { _buildConnectionCheckTile(), _buildProductList(), _buildConsumableBox(), + _buildCodeRedemptionButton(), _buildRestoreButton(), ], ), @@ -429,6 +430,29 @@ class _MyAppState extends State<_MyApp> { ); } + Widget _buildCodeRedemptionButton() { + if (_loading) { + return Container(); + } + + return Padding( + padding: const EdgeInsets.all(4.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + TextButton( + style: TextButton.styleFrom( + backgroundColor: Theme.of(context).colorScheme.primary, + foregroundColor: Colors.white, + ), + onPressed: () => _iapStoreKitPlatformAddition.presentCodeRedemptionSheet(), + child: const Text('Show code redemption sheet'), + ), + ], + ), + ); + } + Widget _buildRestoreButton() { if (_loading) { return Container(); diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/macos/Runner.xcodeproj/project.pbxproj b/packages/in_app_purchase/in_app_purchase_storekit/example/macos/Runner.xcodeproj/project.pbxproj index 772ddc4df5bf..3db40419b6af 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/macos/Runner.xcodeproj/project.pbxproj +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/macos/Runner.xcodeproj/project.pbxproj @@ -27,6 +27,7 @@ 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; + 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; }; F24C45E42C409D87000C6C72 /* InAppPurchasePluginTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F24C45E32C409D87000C6C72 /* InAppPurchasePluginTests.swift */; }; F27694092C4724B200277144 /* ProductRequestHandlerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F27694082C4724B200277144 /* ProductRequestHandlerTests.swift */; }; F27694132C49BF7B00277144 /* FIAPPaymentQueueDeleteTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F27694122C49BF7B00277144 /* FIAPPaymentQueueDeleteTests.swift */; }; @@ -37,7 +38,6 @@ F2D527262C583C1C00C137C7 /* TranslatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2D527252C583C1C00C137C7 /* TranslatorTests.swift */; }; F79BDC1C2905FC3200E3999D /* Stubs.m in Sources */ = {isa = PBXBuildFile; fileRef = F79BDC1B2905FC3200E3999D /* Stubs.m */; }; F8270DE1AEF80A8CF2C45688 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 045C0F7D19875EDA98DF0B7F /* Pods_RunnerTests.framework */; }; - 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -89,6 +89,7 @@ 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; 39C4797E13DFF5FCF1A87568 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 46EFB01DD1BBB34F886C33A0 /* Pods-RunnerTests.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.profile.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.profile.xcconfig"; sourceTree = ""; }; + 78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterGeneratedPluginSwiftPackage; path = ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; AEB2EC182EA43F26A351EE3E /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -201,6 +202,7 @@ 33CEB47122A05771004F2AC0 /* Flutter */ = { isa = PBXGroup; children = ( + 78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */, 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, @@ -245,9 +247,6 @@ /* Begin PBXNativeTarget section */ 33CC10EC2044A3C60003C045 /* Runner */ = { - packageProductDependencies = ( - 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */, - ); isa = PBXNativeTarget; buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( @@ -257,7 +256,6 @@ 33CC10EB2044A3C60003C045 /* Resources */, 33CC110E2044A8840003C045 /* Bundle Framework */, 3399D490228B24CF009A79C7 /* ShellScript */, - 52AE403FA1A5A62558A171B7 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -265,6 +263,9 @@ 33CC11202044C79F0003C045 /* PBXTargetDependency */, ); name = Runner; + packageProductDependencies = ( + 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */, + ); productName = Runner; productReference = 33CC10ED2044A3C60003C045 /* example.app */; productType = "com.apple.product-type.application"; @@ -292,9 +293,6 @@ /* Begin PBXProject section */ 33CC10E52044A3C60003C045 /* Project object */ = { - packageReferences = ( - 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */, - ); isa = PBXProject; attributes = { LastSwiftUpdateCheck = 1400; @@ -331,6 +329,9 @@ Base, ); mainGroup = 33CC10E42044A3C60003C045; + packageReferences = ( + 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */, + ); productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; projectDirPath = ""; projectRoot = ""; @@ -445,23 +446,6 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - 52AE403FA1A5A62558A171B7 /* [CP] Embed Pods Frameworks */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", - ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -887,12 +871,14 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + /* Begin XCLocalSwiftPackageReference section */ - 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */ = { + 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */ = { isa = XCLocalSwiftPackageReference; relativePath = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; }; /* End XCLocalSwiftPackageReference section */ + /* Begin XCSwiftPackageProductDependency section */ 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */ = { isa = XCSwiftPackageProductDependency; diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/pubspec.yaml b/packages/in_app_purchase/in_app_purchase_storekit/example/pubspec.yaml index 7da162d5a658..84fdfa3d929a 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/pubspec.yaml +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/pubspec.yaml @@ -3,8 +3,8 @@ description: Demonstrates how to use the in_app_purchase_storekit plugin. publish_to: none environment: - sdk: ^3.9.0 - flutter: ">=3.35.0" + sdk: ^3.10.0 + flutter: ">=3.38.0" dependencies: flutter: diff --git a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/in_app_purchase_storekit_platform.dart b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/in_app_purchase_storekit_platform.dart index 05c0262027e3..a110e2bf5019 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/in_app_purchase_storekit_platform.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/in_app_purchase_storekit_platform.dart @@ -32,6 +32,7 @@ class InAppPurchaseStoreKitPlatform extends InAppPurchasePlatform { /// Experimental flag for StoreKit2. static bool _useStoreKit2 = true; + bool get isStoreKit2Enabled => _useStoreKit2; /// StoreKit1 static late SKPaymentQueueWrapper _skPaymentQueueWrapper; diff --git a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/in_app_purchase_storekit_platform_addition.dart b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/in_app_purchase_storekit_platform_addition.dart index cd80a5ced25f..0abf263790ce 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/in_app_purchase_storekit_platform_addition.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/in_app_purchase_storekit_platform_addition.dart @@ -7,6 +7,7 @@ import 'package:in_app_purchase_platform_interface/in_app_purchase_platform_inte import '../in_app_purchase_storekit.dart'; import '../store_kit_2_wrappers.dart'; import '../store_kit_wrappers.dart'; +import './in_app_purchase_storekit_platform.dart'; /// Contains InApp Purchase features that are only available on iOS. class InAppPurchaseStoreKitPlatformAddition @@ -23,6 +24,9 @@ class InAppPurchaseStoreKitPlatformAddition /// Available on devices running iOS 14 and iPadOS 14 and later. /// Available for StoreKit 1 and 2 Future presentCodeRedemptionSheet() { + if (InAppPurchaseStoreKitPlatform().isStoreKit2Enabled) { + return AppStore().presentOfferCodeRedeemSheet(); + } return SKPaymentQueueWrapper().presentCodeRedemptionSheet(); } diff --git a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/sk2_pigeon.g.dart b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/sk2_pigeon.g.dart index 8b20981d7d80..41555274daaa 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/sk2_pigeon.g.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/sk2_pigeon.g.dart @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v26.1.5), do not edit directly. +// Autogenerated from Pigeon (v26.1.10), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, omit_obvious_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers @@ -11,18 +11,33 @@ import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; import 'package:flutter/services.dart'; -PlatformException _createConnectionError(String channelName) { - return PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel: "$channelName".', - ); +Object? _extractReplyValueOrThrow( + List? replyList, + String channelName, { + required bool isNullValid, +}) { + if (replyList == null) { + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel: "$channelName".', + ); + } else if (replyList.length > 1) { + throw PlatformException( + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], + ); + } else if (!isNullValid && (replyList.isNotEmpty && replyList[0] == null)) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } + return replyList.firstOrNull; } -List wrapResponse({ - Object? result, - PlatformException? error, - bool empty = false, -}) { + +List wrapResponse({Object? result, PlatformException? error, bool empty = false}) { if (empty) { return []; } @@ -31,40 +46,37 @@ List wrapResponse({ } return [error.code, error.message, error.details]; } - bool _deepEquals(Object? a, Object? b) { if (a is List && b is List) { return a.length == b.length && - a.indexed.every( - ((int, dynamic) item) => _deepEquals(item.$2, b[item.$1]), - ); + a.indexed + .every(((int, dynamic) item) => _deepEquals(item.$2, b[item.$1])); } if (a is Map && b is Map) { - return a.length == b.length && - a.entries.every( - (MapEntry entry) => - (b as Map).containsKey(entry.key) && - _deepEquals(entry.value, b[entry.key]), - ); + return a.length == b.length && a.entries.every((MapEntry entry) => + (b as Map).containsKey(entry.key) && + _deepEquals(entry.value, b[entry.key])); } return a == b; } + enum SK2ProductTypeMessage { /// A consumable in-app purchase. consumable, - /// A non-consumable in-app purchase. nonConsumable, - /// A non-renewing subscription. nonRenewable, - /// An auto-renewable subscription. autoRenewable, } -enum SK2SubscriptionOfferTypeMessage { introductory, promotional, winBack } +enum SK2SubscriptionOfferTypeMessage { + introductory, + promotional, + winBack, +} enum SK2SubscriptionOfferPaymentModeMessage { payAsYouGo, @@ -72,7 +84,12 @@ enum SK2SubscriptionOfferPaymentModeMessage { freeTrial, } -enum SK2SubscriptionPeriodUnitMessage { day, week, month, year } +enum SK2SubscriptionPeriodUnitMessage { + day, + week, + month, + year, +} enum SK2ProductPurchaseResultMessage { success, @@ -86,13 +103,10 @@ enum SK2ProductPurchaseResultMessage { enum SK2PurchaseStatusMessage { /// Purchase completed successfully. purchased, - /// Purchase is pending (e.g., Ask to Buy). pending, - /// Purchase was cancelled by the user. cancelled, - /// Purchase was restored. restored, } @@ -120,12 +134,18 @@ class SK2SubscriptionOfferMessage { SK2SubscriptionOfferPaymentModeMessage paymentMode; List _toList() { - return [id, price, type, period, periodCount, paymentMode]; + return [ + id, + price, + type, + period, + periodCount, + paymentMode, + ]; } Object encode() { - return _toList(); - } + return _toList(); } static SK2SubscriptionOfferMessage decode(Object result) { result as List; @@ -142,8 +162,7 @@ class SK2SubscriptionOfferMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes bool operator ==(Object other) { - if (other is! SK2SubscriptionOfferMessage || - other.runtimeType != runtimeType) { + if (other is! SK2SubscriptionOfferMessage || other.runtimeType != runtimeType) { return false; } if (identical(this, other)) { @@ -154,11 +173,15 @@ class SK2SubscriptionOfferMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()); + int get hashCode => Object.hashAll(_toList()) +; } class SK2SubscriptionPeriodMessage { - SK2SubscriptionPeriodMessage({required this.value, required this.unit}); + SK2SubscriptionPeriodMessage({ + required this.value, + required this.unit, + }); /// The number of units that the period represents. int value; @@ -167,12 +190,14 @@ class SK2SubscriptionPeriodMessage { SK2SubscriptionPeriodUnitMessage unit; List _toList() { - return [value, unit]; + return [ + value, + unit, + ]; } Object encode() { - return _toList(); - } + return _toList(); } static SK2SubscriptionPeriodMessage decode(Object result) { result as List; @@ -185,8 +210,7 @@ class SK2SubscriptionPeriodMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes bool operator ==(Object other) { - if (other is! SK2SubscriptionPeriodMessage || - other.runtimeType != runtimeType) { + if (other is! SK2SubscriptionPeriodMessage || other.runtimeType != runtimeType) { return false; } if (identical(this, other)) { @@ -197,7 +221,8 @@ class SK2SubscriptionPeriodMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()); + int get hashCode => Object.hashAll(_toList()) +; } class SK2SubscriptionInfoMessage { @@ -225,14 +250,12 @@ class SK2SubscriptionInfoMessage { } Object encode() { - return _toList(); - } + return _toList(); } static SK2SubscriptionInfoMessage decode(Object result) { result as List; return SK2SubscriptionInfoMessage( - promotionalOffers: (result[0] as List?)! - .cast(), + promotionalOffers: (result[0] as List?)!.cast(), subscriptionGroupID: result[1]! as String, subscriptionPeriod: result[2]! as SK2SubscriptionPeriodMessage, ); @@ -241,8 +264,7 @@ class SK2SubscriptionInfoMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes bool operator ==(Object other) { - if (other is! SK2SubscriptionInfoMessage || - other.runtimeType != runtimeType) { + if (other is! SK2SubscriptionInfoMessage || other.runtimeType != runtimeType) { return false; } if (identical(this, other)) { @@ -253,7 +275,8 @@ class SK2SubscriptionInfoMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()); + int get hashCode => Object.hashAll(_toList()) +; } /// A Pigeon message class representing a Product @@ -308,8 +331,7 @@ class SK2ProductMessage { } Object encode() { - return _toList(); - } + return _toList(); } static SK2ProductMessage decode(Object result) { result as List; @@ -339,7 +361,8 @@ class SK2ProductMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()); + int get hashCode => Object.hashAll(_toList()) +; } class SK2PriceLocaleMessage { @@ -353,12 +376,14 @@ class SK2PriceLocaleMessage { String currencySymbol; List _toList() { - return [currencyCode, currencySymbol]; + return [ + currencyCode, + currencySymbol, + ]; } Object encode() { - return _toList(); - } + return _toList(); } static SK2PriceLocaleMessage decode(Object result) { result as List; @@ -382,7 +407,8 @@ class SK2PriceLocaleMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()); + int get hashCode => Object.hashAll(_toList()) +; } /// A Pigeon message class representing a Signature @@ -404,12 +430,16 @@ class SK2SubscriptionOfferSignatureMessage { String signature; List _toList() { - return [keyID, nonce, timestamp, signature]; + return [ + keyID, + nonce, + timestamp, + signature, + ]; } Object encode() { - return _toList(); - } + return _toList(); } static SK2SubscriptionOfferSignatureMessage decode(Object result) { result as List; @@ -424,8 +454,7 @@ class SK2SubscriptionOfferSignatureMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes bool operator ==(Object other) { - if (other is! SK2SubscriptionOfferSignatureMessage || - other.runtimeType != runtimeType) { + if (other is! SK2SubscriptionOfferSignatureMessage || other.runtimeType != runtimeType) { return false; } if (identical(this, other)) { @@ -436,7 +465,8 @@ class SK2SubscriptionOfferSignatureMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()); + int get hashCode => Object.hashAll(_toList()) +; } class SK2SubscriptionOfferPurchaseMessage { @@ -450,27 +480,27 @@ class SK2SubscriptionOfferPurchaseMessage { SK2SubscriptionOfferSignatureMessage promotionalOfferSignature; List _toList() { - return [promotionalOfferId, promotionalOfferSignature]; + return [ + promotionalOfferId, + promotionalOfferSignature, + ]; } Object encode() { - return _toList(); - } + return _toList(); } static SK2SubscriptionOfferPurchaseMessage decode(Object result) { result as List; return SK2SubscriptionOfferPurchaseMessage( promotionalOfferId: result[0]! as String, - promotionalOfferSignature: - result[1]! as SK2SubscriptionOfferSignatureMessage, + promotionalOfferSignature: result[1]! as SK2SubscriptionOfferSignatureMessage, ); } @override // ignore: avoid_equals_and_hash_code_on_mutable_classes bool operator ==(Object other) { - if (other is! SK2SubscriptionOfferPurchaseMessage || - other.runtimeType != runtimeType) { + if (other is! SK2SubscriptionOfferPurchaseMessage || other.runtimeType != runtimeType) { return false; } if (identical(this, other)) { @@ -481,7 +511,8 @@ class SK2SubscriptionOfferPurchaseMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()); + int get hashCode => Object.hashAll(_toList()) +; } class SK2ProductPurchaseOptionsMessage { @@ -510,8 +541,7 @@ class SK2ProductPurchaseOptionsMessage { } Object encode() { - return _toList(); - } + return _toList(); } static SK2ProductPurchaseOptionsMessage decode(Object result) { result as List; @@ -526,8 +556,7 @@ class SK2ProductPurchaseOptionsMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes bool operator ==(Object other) { - if (other is! SK2ProductPurchaseOptionsMessage || - other.runtimeType != runtimeType) { + if (other is! SK2ProductPurchaseOptionsMessage || other.runtimeType != runtimeType) { return false; } if (identical(this, other)) { @@ -538,7 +567,8 @@ class SK2ProductPurchaseOptionsMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()); + int get hashCode => Object.hashAll(_toList()) +; } class SK2TransactionMessage { @@ -597,8 +627,7 @@ class SK2TransactionMessage { } Object encode() { - return _toList(); - } + return _toList(); } static SK2TransactionMessage decode(Object result) { result as List; @@ -631,11 +660,16 @@ class SK2TransactionMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()); + int get hashCode => Object.hashAll(_toList()) +; } class SK2ErrorMessage { - SK2ErrorMessage({required this.code, required this.domain, this.userInfo}); + SK2ErrorMessage({ + required this.code, + required this.domain, + this.userInfo, + }); int code; @@ -644,12 +678,15 @@ class SK2ErrorMessage { Map? userInfo; List _toList() { - return [code, domain, userInfo]; + return [ + code, + domain, + userInfo, + ]; } Object encode() { - return _toList(); - } + return _toList(); } static SK2ErrorMessage decode(Object result) { result as List; @@ -674,9 +711,11 @@ class SK2ErrorMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()); + int get hashCode => Object.hashAll(_toList()) +; } + class _PigeonCodec extends StandardMessageCodec { const _PigeonCodec(); @override @@ -684,52 +723,52 @@ class _PigeonCodec extends StandardMessageCodec { if (value is int) { buffer.putUint8(4); buffer.putInt64(value); - } else if (value is SK2ProductTypeMessage) { + } else if (value is SK2ProductTypeMessage) { buffer.putUint8(129); writeValue(buffer, value.index); - } else if (value is SK2SubscriptionOfferTypeMessage) { + } else if (value is SK2SubscriptionOfferTypeMessage) { buffer.putUint8(130); writeValue(buffer, value.index); - } else if (value is SK2SubscriptionOfferPaymentModeMessage) { + } else if (value is SK2SubscriptionOfferPaymentModeMessage) { buffer.putUint8(131); writeValue(buffer, value.index); - } else if (value is SK2SubscriptionPeriodUnitMessage) { + } else if (value is SK2SubscriptionPeriodUnitMessage) { buffer.putUint8(132); writeValue(buffer, value.index); - } else if (value is SK2ProductPurchaseResultMessage) { + } else if (value is SK2ProductPurchaseResultMessage) { buffer.putUint8(133); writeValue(buffer, value.index); - } else if (value is SK2PurchaseStatusMessage) { + } else if (value is SK2PurchaseStatusMessage) { buffer.putUint8(134); writeValue(buffer, value.index); - } else if (value is SK2SubscriptionOfferMessage) { + } else if (value is SK2SubscriptionOfferMessage) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else if (value is SK2SubscriptionPeriodMessage) { + } else if (value is SK2SubscriptionPeriodMessage) { buffer.putUint8(136); writeValue(buffer, value.encode()); - } else if (value is SK2SubscriptionInfoMessage) { + } else if (value is SK2SubscriptionInfoMessage) { buffer.putUint8(137); writeValue(buffer, value.encode()); - } else if (value is SK2ProductMessage) { + } else if (value is SK2ProductMessage) { buffer.putUint8(138); writeValue(buffer, value.encode()); - } else if (value is SK2PriceLocaleMessage) { + } else if (value is SK2PriceLocaleMessage) { buffer.putUint8(139); writeValue(buffer, value.encode()); - } else if (value is SK2SubscriptionOfferSignatureMessage) { + } else if (value is SK2SubscriptionOfferSignatureMessage) { buffer.putUint8(140); writeValue(buffer, value.encode()); - } else if (value is SK2SubscriptionOfferPurchaseMessage) { + } else if (value is SK2SubscriptionOfferPurchaseMessage) { buffer.putUint8(141); writeValue(buffer, value.encode()); - } else if (value is SK2ProductPurchaseOptionsMessage) { + } else if (value is SK2ProductPurchaseOptionsMessage) { buffer.putUint8(142); writeValue(buffer, value.encode()); - } else if (value is SK2TransactionMessage) { + } else if (value is SK2TransactionMessage) { buffer.putUint8(143); writeValue(buffer, value.encode()); - } else if (value is SK2ErrorMessage) { + } else if (value is SK2ErrorMessage) { buffer.putUint8(144); writeValue(buffer, value.encode()); } else { @@ -745,24 +784,16 @@ class _PigeonCodec extends StandardMessageCodec { return value == null ? null : SK2ProductTypeMessage.values[value]; case 130: final value = readValue(buffer) as int?; - return value == null - ? null - : SK2SubscriptionOfferTypeMessage.values[value]; + return value == null ? null : SK2SubscriptionOfferTypeMessage.values[value]; case 131: final value = readValue(buffer) as int?; - return value == null - ? null - : SK2SubscriptionOfferPaymentModeMessage.values[value]; + return value == null ? null : SK2SubscriptionOfferPaymentModeMessage.values[value]; case 132: final value = readValue(buffer) as int?; - return value == null - ? null - : SK2SubscriptionPeriodUnitMessage.values[value]; + return value == null ? null : SK2SubscriptionPeriodUnitMessage.values[value]; case 133: final value = readValue(buffer) as int?; - return value == null - ? null - : SK2ProductPurchaseResultMessage.values[value]; + return value == null ? null : SK2ProductPurchaseResultMessage.values[value]; case 134: final value = readValue(buffer) as int?; return value == null ? null : SK2PurchaseStatusMessage.values[value]; @@ -796,13 +827,9 @@ class InAppPurchase2API { /// Constructor for [InAppPurchase2API]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - InAppPurchase2API({ - BinaryMessenger? binaryMessenger, - String messageChannelSuffix = '', - }) : pigeonVar_binaryMessenger = binaryMessenger, - pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty - ? '.$messageChannelSuffix' - : ''; + InAppPurchase2API({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) + : pigeonVar_binaryMessenger = binaryMessenger, + pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; final BinaryMessenger? pigeonVar_binaryMessenger; static const MessageCodec pigeonChannelCodec = _PigeonCodec(); @@ -810,8 +837,7 @@ class InAppPurchase2API { final String pigeonVar_messageChannelSuffix; Future canMakePayments() async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.canMakePayments$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.canMakePayments$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -819,151 +845,94 @@ class InAppPurchase2API { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as bool?)!; - } + + final Object pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ) + !; + return pigeonVar_replyValue as bool; } Future> products(List identifiers) async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.products$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.products$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send( - [identifiers], - ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([identifiers]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as List?)! - .cast(); - } + + final Object pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ) + !; + return (pigeonVar_replyValue as List).cast(); } - Future purchase( - String id, { - SK2ProductPurchaseOptionsMessage? options, - }) async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.purchase$pigeonVar_messageChannelSuffix'; + Future purchase(String id, {SK2ProductPurchaseOptionsMessage? options}) async { + final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.purchase$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send( - [id, options], - ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([id, options]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as SK2ProductPurchaseResultMessage?)!; - } + + final Object pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ) + !; + return pigeonVar_replyValue as SK2ProductPurchaseResultMessage; } Future isWinBackOfferEligible(String productId, String offerId) async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.isWinBackOfferEligible$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.isWinBackOfferEligible$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send( - [productId, offerId], - ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([productId, offerId]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as bool?)!; - } + + final Object pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ) + !; + return pigeonVar_replyValue as bool; } Future isIntroductoryOfferEligible(String productId) async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.isIntroductoryOfferEligible$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.isIntroductoryOfferEligible$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send( - [productId], - ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([productId]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as bool?)!; - } + + final Object pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ) + !; + return pigeonVar_replyValue as bool; } Future> transactions() async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.transactions$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.transactions$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -971,28 +940,18 @@ class InAppPurchase2API { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as List?)! - .cast(); - } + + final Object pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ) + !; + return (pigeonVar_replyValue as List).cast(); } Future> unfinishedTransactions() async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.unfinishedTransactions$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.unfinishedTransactions$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -1000,53 +959,36 @@ class InAppPurchase2API { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as List?)! - .cast(); - } + + final Object pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ) + !; + return (pigeonVar_replyValue as List).cast(); } Future finish(int id) async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.finish$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.finish$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send( - [id], - ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([id]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } Future startListeningToTransactions() async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.startListeningToTransactions$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.startListeningToTransactions$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -1054,22 +996,17 @@ class InAppPurchase2API { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } Future stopListeningToTransactions() async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.stopListeningToTransactions$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.stopListeningToTransactions$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -1077,22 +1014,17 @@ class InAppPurchase2API { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } Future restorePurchases() async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.restorePurchases$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.restorePurchases$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -1100,22 +1032,17 @@ class InAppPurchase2API { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } Future countryCode() async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.countryCode$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.countryCode$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -1123,27 +1050,18 @@ class InAppPurchase2API { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as String?)!; - } + + final Object pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ) + !; + return pigeonVar_replyValue as String; } Future sync() async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.sync$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.sync$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -1151,17 +1069,31 @@ class InAppPurchase2API { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; + } + + Future presentOfferCodeRedeemSheet() async { + final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.presentOfferCodeRedeemSheet$pigeonVar_messageChannelSuffix'; + final pigeonVar_channel = BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); + final pigeonVar_replyList = await pigeonVar_sendFuture as List?; + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } } @@ -1170,44 +1102,29 @@ abstract class InAppPurchase2CallbackAPI { void onTransactionsUpdated(List newTransactions); - static void setUp( - InAppPurchase2CallbackAPI? api, { - BinaryMessenger? binaryMessenger, - String messageChannelSuffix = '', - }) { - messageChannelSuffix = messageChannelSuffix.isNotEmpty - ? '.$messageChannelSuffix' - : ''; + static void setUp(InAppPurchase2CallbackAPI? api, {BinaryMessenger? binaryMessenger, String messageChannelSuffix = '',}) { + messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; { final pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2CallbackAPI.onTransactionsUpdated$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger, - ); + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2CallbackAPI.onTransactionsUpdated$messageChannelSuffix', pigeonChannelCodec, + binaryMessenger: binaryMessenger); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2CallbackAPI.onTransactionsUpdated was null.', - ); + assert(message != null, + 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2CallbackAPI.onTransactionsUpdated was null.'); final List args = (message as List?)!; - final List? arg_newTransactions = - (args[0] as List?)?.cast(); - assert( - arg_newTransactions != null, - 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2CallbackAPI.onTransactionsUpdated was null, expected non-null List.', - ); + final List? arg_newTransactions = (args[0] as List?)?.cast(); + assert(arg_newTransactions != null, + 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2CallbackAPI.onTransactionsUpdated was null, expected non-null List.'); try { api.onTransactionsUpdated(arg_newTransactions!); return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse( - error: PlatformException(code: 'error', message: e.toString()), - ); + } catch (e) { + return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); } }); } diff --git a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_2_wrappers/sk2_appstore_wrapper.dart b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_2_wrappers/sk2_appstore_wrapper.dart index 8bfc8e478935..77b3d13309e1 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_2_wrappers/sk2_appstore_wrapper.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_2_wrappers/sk2_appstore_wrapper.dart @@ -21,4 +21,9 @@ final class AppStore { Future sync() { return hostApi2.sync(); } + + /// fuck + Future presentOfferCodeRedeemSheet() { + return hostApi2.presentOfferCodeRedeemSheet(); + } } diff --git a/packages/in_app_purchase/in_app_purchase_storekit/pigeons/sk2_pigeon.dart b/packages/in_app_purchase/in_app_purchase_storekit/pigeons/sk2_pigeon.dart index f318ec5277e0..067e7d5a8ce8 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/pigeons/sk2_pigeon.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/pigeons/sk2_pigeon.dart @@ -277,6 +277,9 @@ abstract class InAppPurchase2API { @async void sync(); + + @async + void presentOfferCodeRedeemSheet(); } @FlutterApi() From 6ec5914a06573d55087e4e8c1b46dba2999b2e57 Mon Sep 17 00:00:00 2001 From: louisehsu Date: Wed, 11 Mar 2026 13:14:50 -0700 Subject: [PATCH 2/6] uiscene + test --- .../InAppPurchasePlugin+StoreKit2.swift | 12 +++++------ .../ios/Runner.xcodeproj/project.pbxproj | 20 ++++++++++++------- .../test/fakes/fake_storekit_platform.dart | 3 +++ 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2/InAppPurchasePlugin+StoreKit2.swift b/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2/InAppPurchasePlugin+StoreKit2.swift index c1f71e696766..2361dcaa34f4 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2/InAppPurchasePlugin+StoreKit2.swift +++ b/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2/InAppPurchasePlugin+StoreKit2.swift @@ -3,6 +3,7 @@ // found in the LICENSE file. import StoreKit +import SwiftUI @available(iOS 15.0, macOS 12.0, *) extension InAppPurchasePlugin: InAppPurchase2API { @@ -324,14 +325,13 @@ extension InAppPurchasePlugin: InAppPurchase2API { func presentOfferCodeRedeemSheet(completion: @escaping (Result) -> Void) { if #available(iOS 16.0, *) { let windowScene = self.registrar?.viewController?.view.window?.windowScene - Task { do { - try await AppStore.presentOfferCodeRedeemSheet(in: windowScene!) - completion(.success(())) - } catch { - completion(.failure(error)) - } + try await AppStore.presentOfferCodeRedeemSheet(in: windowScene!) + completion(.success(())) + } catch { + completion(.failure(error)) + } } } } diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner.xcodeproj/project.pbxproj b/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner.xcodeproj/project.pbxproj index c0a2696fa1d0..3dc88a0e6306 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 54; + objectVersion = 60; objects = { /* Begin PBXBuildFile section */ @@ -303,7 +303,7 @@ ); mainGroup = 97C146E51CF9000F007C117D; packageReferences = ( - 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */, + 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */, ); productRefGroup = 97C146EF1CF9000F007C117D /* Products */; projectDirPath = ""; @@ -584,8 +584,10 @@ baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = S8QB4VV633; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -602,6 +604,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.inAppPurchaseExample; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; VERSIONING_SYSTEM = "apple-generic"; }; name = Debug; @@ -611,8 +614,10 @@ baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = S8QB4VV633; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -629,6 +634,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.inAppPurchaseExample; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; VERSIONING_SYSTEM = "apple-generic"; }; name = Release; @@ -646,7 +652,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = S8QB4VV633; INFOPLIST_FILE = RunnerTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -677,7 +683,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = S8QB4VV633; INFOPLIST_FILE = RunnerTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -726,7 +732,7 @@ /* End XCConfigurationList section */ /* Begin XCLocalSwiftPackageReference section */ - 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "FlutterGeneratedPluginSwiftPackage" */ = { + 781AD8BC2B33823900A9FFBB /* XCLocalSwiftPackageReference "Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage" */ = { isa = XCLocalSwiftPackageReference; relativePath = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; }; diff --git a/packages/in_app_purchase/in_app_purchase_storekit/test/fakes/fake_storekit_platform.dart b/packages/in_app_purchase/in_app_purchase_storekit/test/fakes/fake_storekit_platform.dart index 517670f8c8ae..55a00a27cbdc 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/test/fakes/fake_storekit_platform.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/test/fakes/fake_storekit_platform.dart @@ -583,6 +583,9 @@ class FakeStoreKit2Platform implements InAppPurchase2API { @override // ignore: non_constant_identifier_names String get pigeonVar_messageChannelSuffix => ''; + + @override + Future presentOfferCodeRedeemSheet() async {} } SK2TransactionMessage createPendingTransaction(String id, {int quantity = 1}) { From f0a9d8046b0bdec15a427cf27071e06a277cf50c Mon Sep 17 00:00:00 2001 From: louisehsu Date: Thu, 12 Mar 2026 13:54:39 -0700 Subject: [PATCH 3/6] test --- .../InAppPurchasePlugin+StoreKit2.swift | 14 ++++++++++--- .../InAppPurchaseStoreKit2PluginTests.swift | 21 ++++++++++++++++--- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2/InAppPurchasePlugin+StoreKit2.swift b/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2/InAppPurchasePlugin+StoreKit2.swift index 2361dcaa34f4..6a05d4dced25 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2/InAppPurchasePlugin+StoreKit2.swift +++ b/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2/InAppPurchasePlugin+StoreKit2.swift @@ -3,7 +3,6 @@ // found in the LICENSE file. import StoreKit -import SwiftUI @available(iOS 15.0, macOS 12.0, *) extension InAppPurchasePlugin: InAppPurchase2API { @@ -324,10 +323,19 @@ extension InAppPurchasePlugin: InAppPurchase2API { func presentOfferCodeRedeemSheet(completion: @escaping (Result) -> Void) { if #available(iOS 16.0, *) { - let windowScene = self.registrar?.viewController?.view.window?.windowScene + guard #available(iOS 16.0, *), + let windowScene = self.registrar?.viewController?.view.window?.windowScene else { + let error = PigeonError( + code: "storekit2_missing_key_window_scene", + message: "Failed to fetch key window", + details: "Storefront.current returned nil." + ) + completion(.failure(error)) + return + } Task { do { - try await AppStore.presentOfferCodeRedeemSheet(in: windowScene!) + try await AppStore.presentOfferCodeRedeemSheet(in: windowScene) completion(.success(())) } catch { completion(.failure(error)) diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift b/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift index 88abb2ff063d..5b6de44d82ee 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift @@ -227,7 +227,7 @@ final class InAppPurchase2PluginTests: XCTestCase { case .failure(let error): XCTAssertEqual( error.localizedDescription, - "The operation couldn’t be completed. (NSURLErrorDomain error -1009.)") + "The operation couldn’t be completed. (in_app_purchase_storekit.PigeonError error 1.)") expectation.fulfill() } } @@ -290,7 +290,7 @@ final class InAppPurchase2PluginTests: XCTestCase { XCTFail("Purchase should NOT fail. Failed with \(error)") } } - await fulfillment(of: [expectation], timeout: 5) + await fulfillment(of: [expectation], timeout: 10) } func testDiscountedProductSuccess() async throws { @@ -303,7 +303,7 @@ final class InAppPurchase2PluginTests: XCTestCase { XCTFail("Purchase should NOT fail. Failed with \(error)") } } - await fulfillment(of: [expectation], timeout: 5) + await fulfillment(of: [expectation], timeout: 10) } func testPurchaseWithAppAccountToken() async throws { @@ -531,4 +531,19 @@ final class InAppPurchase2PluginTests: XCTestCase { await fulfillment(of: [expectation], timeout: 5) } + @available(iOS 16.0, macOS 15.0, *) + func testRedeemCodeSheetFailsGracefullyWhenNoWindow() { + let expectation = self.expectation(description: "Should fail gracefully when without key window") + + plugin.registrar = nil + + plugin.presentOfferCodeRedeemSheet { result in + if case .failure = result { + expectation.fulfill() + } + } + + waitForExpectations(timeout: 1.0) + } + } From 11818fb5c3c9ada6d5f8194edb6f1807cd0ab745 Mon Sep 17 00:00:00 2001 From: louisehsu Date: Thu, 12 Mar 2026 16:23:25 -0700 Subject: [PATCH 4/6] test --- .../lib/src/in_app_purchase_storekit_platform.dart | 1 - ..._app_purchase_storekit_platform_addtion_test.dart | 12 +++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/in_app_purchase_storekit_platform.dart b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/in_app_purchase_storekit_platform.dart index a110e2bf5019..cf25c1cc4696 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/in_app_purchase_storekit_platform.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/in_app_purchase_storekit_platform.dart @@ -27,7 +27,6 @@ class InAppPurchaseStoreKitPlatform extends InAppPurchasePlatform { /// /// This constructor should only be used for testing, for any other purpose /// get the connection from the [instance] getter. - @visibleForTesting InAppPurchaseStoreKitPlatform(); /// Experimental flag for StoreKit2. diff --git a/packages/in_app_purchase/in_app_purchase_storekit/test/in_app_purchase_storekit_platform_addtion_test.dart b/packages/in_app_purchase/in_app_purchase_storekit/test/in_app_purchase_storekit_platform_addtion_test.dart index b73b62681392..ab77534e3eb1 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/test/in_app_purchase_storekit_platform_addtion_test.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/test/in_app_purchase_storekit_platform_addtion_test.dart @@ -19,7 +19,17 @@ void main() { }); group('present code redemption sheet', () { - test('null', () async { + test('in storekit 1', () async { + await InAppPurchaseStoreKitPlatform.enableStoreKit1(); + expect( + InAppPurchaseStoreKitPlatformAddition().presentCodeRedemptionSheet(), + completes, + ); + }); + }); + + group('present code redemption sheet', () { + test('in storekit 2', () async { expect( InAppPurchaseStoreKitPlatformAddition().presentCodeRedemptionSheet(), completes, From 8a578274acf2e644071e4514c2c878bbfce26e91 Mon Sep 17 00:00:00 2001 From: louisehsu Date: Thu, 12 Mar 2026 16:32:21 -0700 Subject: [PATCH 5/6] . --- .../ios/Runner.xcodeproj/project.pbxproj | 6 ++- .../example/ios/Runner/Info.plist | 46 +++++++++---------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner.xcodeproj/project.pbxproj b/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner.xcodeproj/project.pbxproj index 3dc88a0e6306..72a472ca29cd 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner.xcodeproj/project.pbxproj @@ -602,7 +602,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.inAppPurchaseExample; + PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.inAppPurchaseExample9; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; VERSIONING_SYSTEM = "apple-generic"; @@ -632,7 +632,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.inAppPurchaseExample; + PRODUCT_BUNDLE_IDENTIFIER = dev.flutter.plugins.inAppPurchaseExample9; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; VERSIONING_SYSTEM = "apple-generic"; @@ -651,6 +651,7 @@ CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = S8QB4VV633; INFOPLIST_FILE = RunnerTests/Info.plist; @@ -682,6 +683,7 @@ CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = S8QB4VV633; INFOPLIST_FILE = RunnerTests/Info.plist; diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner/Info.plist b/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner/Info.plist index 4975762308f5..d47762e99d03 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner/Info.plist +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner/Info.plist @@ -2,6 +2,8 @@ + CADisableMinimumFrameDurationOnPhone + CFBundleDevelopmentRegion en CFBundleExecutable @@ -22,27 +24,6 @@ 1 LSRequiresIPhoneOS - UILaunchStoryboardName - LaunchScreen - UIMainStoryboardFile - Main - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - CADisableMinimumFrameDurationOnPhone - - UIApplicationSupportsIndirectInputEvents - UIApplicationSceneManifest UIApplicationSupportsMultipleScenes @@ -54,15 +35,34 @@ UISceneClassName UIWindowScene - UISceneDelegateClassName - FlutterSceneDelegate UISceneConfigurationName flutter + UISceneDelegateClassName + FlutterSceneDelegate UISceneStoryboardFile Main + UIApplicationSupportsIndirectInputEvents + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + From c18ff02c68eb2566ef7f0425b5fba9af37406391 Mon Sep 17 00:00:00 2001 From: louisehsu Date: Thu, 12 Mar 2026 18:42:19 -0700 Subject: [PATCH 6/6] format, macos fixes --- .../InAppPurchasePlugin.swift | 10 +- .../InAppPurchasePlugin+StoreKit2.swift | 46 +- .../StoreKit2/StoreKit2Messages.g.swift | 172 +++++-- .../messages.g.m | 10 +- .../ios/Runner.xcodeproj/project.pbxproj | 2 +- .../example/ios/Runner/AppDelegate.m | 2 +- .../example/lib/main.dart | 3 +- .../macos/Runner.xcodeproj/project.pbxproj | 2 +- .../InAppPurchaseStoreKit2PluginTests.swift | 3 +- .../lib/src/sk2_pigeon.g.dart | 475 +++++++++--------- 10 files changed, 419 insertions(+), 306 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/InAppPurchasePlugin.swift b/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/InAppPurchasePlugin.swift index 175a573dbc80..6192b6359594 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/InAppPurchasePlugin.swift +++ b/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/InAppPurchasePlugin.swift @@ -15,7 +15,7 @@ import StoreKit import FlutterMacOS #endif -public class InAppPurchasePlugin: NSObject, FlutterPlugin, FIAInAppPurchaseAPI, FlutterSceneLifeCycleDelegate { +public class InAppPurchasePlugin: NSObject, FlutterPlugin, FIAInAppPurchaseAPI { private let receiptManager: FIAPReceiptManager private var productsCache: NSMutableDictionary = [:] private var paymentQueueDelegateCallbackChannel: FlutterMethodChannel? @@ -60,7 +60,9 @@ public class InAppPurchasePlugin: NSObject, FlutterPlugin, FIAInAppPurchaseAPI, SetUpFIAInAppPurchaseAPI(messenger, instance) if #available(iOS 15.0, macOS 12.0, *) { InAppPurchase2APISetup.setUp(binaryMessenger: messenger, api: instance) - registrar.addSceneDelegate(instance) + #if os(iOS) + registrar.addSceneDelegate(instance) + #endif } } @@ -466,3 +468,7 @@ public class InAppPurchasePlugin: NSObject, FlutterPlugin, FIAInAppPurchaseAPI, ) } } + +#if os(iOS) + extension InAppPurchasePlugin: FlutterSceneLifeCycleDelegate {} +#endif diff --git a/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2/InAppPurchasePlugin+StoreKit2.swift b/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2/InAppPurchasePlugin+StoreKit2.swift index 6a05d4dced25..88083d2450bd 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2/InAppPurchasePlugin+StoreKit2.swift +++ b/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2/InAppPurchasePlugin+StoreKit2.swift @@ -322,26 +322,48 @@ extension InAppPurchasePlugin: InAppPurchase2API { } func presentOfferCodeRedeemSheet(completion: @escaping (Result) -> Void) { - if #available(iOS 16.0, *) { - guard #available(iOS 16.0, *), - let windowScene = self.registrar?.viewController?.view.window?.windowScene else { - let error = PigeonError( - code: "storekit2_missing_key_window_scene", - message: "Failed to fetch key window", - details: "Storefront.current returned nil." - ) + #if os(iOS) + if #available(iOS 16.0, *) { + guard let windowScene = self.registrar?.viewController?.view.window?.windowScene else { + let error = PigeonError( + code: "storekit2_missing_key_window_scene", + message: "Failed to fetch key window scene", + details: "registrar.viewController.view.window.windowScene returned nil." + ) completion(.failure(error)) return } - Task { - do { - try await AppStore.presentOfferCodeRedeemSheet(in: windowScene) + Task { @MainActor in + do { + try await AppStore.presentOfferCodeRedeemSheet(in: windowScene) completion(.success(())) } catch { completion(.failure(error)) } + } } - } + #elseif os(macOS) + if #available(macOS 15.0, *) { + guard let viewController = self.registrar?.viewController else { + let error = PigeonError( + code: "storekit2_missing_view_controller", + message: "Failed to fetch view controller", + details: "registrar.viewController returned nil." + ) + completion(.failure(error)) + return + } + + Task { @MainActor in + do { + try await AppStore.presentOfferCodeRedeemSheet(from: viewController) + completion(.success(())) + } catch { + completion(.failure(error)) + } + } + } + #endif } /// Wrapper method around StoreKit2's sync() method diff --git a/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2/StoreKit2Messages.g.swift b/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2/StoreKit2Messages.g.swift index 7ebba1df5a2c..dc75c7dae891 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2/StoreKit2Messages.g.swift +++ b/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/StoreKit2/StoreKit2Messages.g.swift @@ -59,7 +59,9 @@ private func wrapError(_ error: Any) -> [Any?] { } private func createConnectionError(withChannelName channelName: String) -> PigeonError { - return PigeonError(code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.", details: "") + return PigeonError( + code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.", + details: "") } private func isNullish(_ value: Any?) -> Bool { @@ -114,12 +116,12 @@ func deepEqualsStoreKit2Messages(_ lhs: Any?, _ rhs: Any?) -> Bool { func deepHashStoreKit2Messages(value: Any?, hasher: inout Hasher) { if let valueList = value as? [AnyHashable] { - for item in valueList { deepHashStoreKit2Messages(value: item, hasher: &hasher) } - return + for item in valueList { deepHashStoreKit2Messages(value: item, hasher: &hasher) } + return } if let valueDict = value as? [AnyHashable: AnyHashable] { - for key in valueDict.keys { + for key in valueDict.keys { hasher.combine(key) deepHashStoreKit2Messages(value: valueDict[key]!, hasher: &hasher) } @@ -133,8 +135,6 @@ func deepHashStoreKit2Messages(value: Any?, hasher: inout Hasher) { return hasher.combine(String(describing: value)) } - - enum SK2ProductTypeMessage: Int { /// A consumable in-app purchase. case consumable = 0 @@ -194,7 +194,6 @@ struct SK2SubscriptionOfferMessage: Hashable { var periodCount: Int64 var paymentMode: SK2SubscriptionOfferPaymentModeMessage - // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2SubscriptionOfferMessage? { let id: String? = nilOrValue(pigeonVar_list[0]) @@ -224,7 +223,8 @@ struct SK2SubscriptionOfferMessage: Hashable { ] } static func == (lhs: SK2SubscriptionOfferMessage, rhs: SK2SubscriptionOfferMessage) -> Bool { - return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) } + return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) + } func hash(into hasher: inout Hasher) { deepHashStoreKit2Messages(value: toList(), hasher: &hasher) } @@ -237,7 +237,6 @@ struct SK2SubscriptionPeriodMessage: Hashable { /// The unit of time that this period represents. var unit: SK2SubscriptionPeriodUnitMessage - // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2SubscriptionPeriodMessage? { let value = pigeonVar_list[0] as! Int64 @@ -255,7 +254,8 @@ struct SK2SubscriptionPeriodMessage: Hashable { ] } static func == (lhs: SK2SubscriptionPeriodMessage, rhs: SK2SubscriptionPeriodMessage) -> Bool { - return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) } + return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) + } func hash(into hasher: inout Hasher) { deepHashStoreKit2Messages(value: toList(), hasher: &hasher) } @@ -270,7 +270,6 @@ struct SK2SubscriptionInfoMessage: Hashable { /// The duration that this subscription lasts before auto-renewing. var subscriptionPeriod: SK2SubscriptionPeriodMessage - // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2SubscriptionInfoMessage? { let promotionalOffers = pigeonVar_list[0] as! [SK2SubscriptionOfferMessage] @@ -291,7 +290,8 @@ struct SK2SubscriptionInfoMessage: Hashable { ] } static func == (lhs: SK2SubscriptionInfoMessage, rhs: SK2SubscriptionInfoMessage) -> Bool { - return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) } + return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) + } func hash(into hasher: inout Hasher) { deepHashStoreKit2Messages(value: toList(), hasher: &hasher) } @@ -319,7 +319,6 @@ struct SK2ProductMessage: Hashable { /// The currency and locale information for this product var priceLocale: SK2PriceLocaleMessage - // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2ProductMessage? { let id = pigeonVar_list[0] as! String @@ -355,7 +354,8 @@ struct SK2ProductMessage: Hashable { ] } static func == (lhs: SK2ProductMessage, rhs: SK2ProductMessage) -> Bool { - return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) } + return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) + } func hash(into hasher: inout Hasher) { deepHashStoreKit2Messages(value: toList(), hasher: &hasher) } @@ -366,7 +366,6 @@ struct SK2PriceLocaleMessage: Hashable { var currencyCode: String var currencySymbol: String - // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2PriceLocaleMessage? { let currencyCode = pigeonVar_list[0] as! String @@ -384,7 +383,8 @@ struct SK2PriceLocaleMessage: Hashable { ] } static func == (lhs: SK2PriceLocaleMessage, rhs: SK2PriceLocaleMessage) -> Bool { - return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) } + return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) + } func hash(into hasher: inout Hasher) { deepHashStoreKit2Messages(value: toList(), hasher: &hasher) } @@ -400,7 +400,6 @@ struct SK2SubscriptionOfferSignatureMessage: Hashable { var timestamp: Int64 var signature: String - // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2SubscriptionOfferSignatureMessage? { let keyID = pigeonVar_list[0] as! String @@ -423,8 +422,11 @@ struct SK2SubscriptionOfferSignatureMessage: Hashable { signature, ] } - static func == (lhs: SK2SubscriptionOfferSignatureMessage, rhs: SK2SubscriptionOfferSignatureMessage) -> Bool { - return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) } + static func == ( + lhs: SK2SubscriptionOfferSignatureMessage, rhs: SK2SubscriptionOfferSignatureMessage + ) -> Bool { + return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) + } func hash(into hasher: inout Hasher) { deepHashStoreKit2Messages(value: toList(), hasher: &hasher) } @@ -435,7 +437,6 @@ struct SK2SubscriptionOfferPurchaseMessage: Hashable { var promotionalOfferId: String var promotionalOfferSignature: SK2SubscriptionOfferSignatureMessage - // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2SubscriptionOfferPurchaseMessage? { let promotionalOfferId = pigeonVar_list[0] as! String @@ -452,8 +453,11 @@ struct SK2SubscriptionOfferPurchaseMessage: Hashable { promotionalOfferSignature, ] } - static func == (lhs: SK2SubscriptionOfferPurchaseMessage, rhs: SK2SubscriptionOfferPurchaseMessage) -> Bool { - return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) } + static func == ( + lhs: SK2SubscriptionOfferPurchaseMessage, rhs: SK2SubscriptionOfferPurchaseMessage + ) -> Bool { + return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) + } func hash(into hasher: inout Hasher) { deepHashStoreKit2Messages(value: toList(), hasher: &hasher) } @@ -466,7 +470,6 @@ struct SK2ProductPurchaseOptionsMessage: Hashable { var promotionalOffer: SK2SubscriptionOfferPurchaseMessage? = nil var winBackOfferId: String? = nil - // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2ProductPurchaseOptionsMessage? { let appAccountToken: String? = nilOrValue(pigeonVar_list[0]) @@ -489,8 +492,11 @@ struct SK2ProductPurchaseOptionsMessage: Hashable { winBackOfferId, ] } - static func == (lhs: SK2ProductPurchaseOptionsMessage, rhs: SK2ProductPurchaseOptionsMessage) -> Bool { - return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) } + static func == (lhs: SK2ProductPurchaseOptionsMessage, rhs: SK2ProductPurchaseOptionsMessage) + -> Bool + { + return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) + } func hash(into hasher: inout Hasher) { deepHashStoreKit2Messages(value: toList(), hasher: &hasher) } @@ -512,7 +518,6 @@ struct SK2TransactionMessage: Hashable { /// Set by native side to communicate the result state to Dart layer. var status: SK2PurchaseStatusMessage - // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2TransactionMessage? { let id = pigeonVar_list[0] as! Int64 @@ -557,7 +562,8 @@ struct SK2TransactionMessage: Hashable { ] } static func == (lhs: SK2TransactionMessage, rhs: SK2TransactionMessage) -> Bool { - return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) } + return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) + } func hash(into hasher: inout Hasher) { deepHashStoreKit2Messages(value: toList(), hasher: &hasher) } @@ -569,7 +575,6 @@ struct SK2ErrorMessage: Hashable { var domain: String var userInfo: [String: Any]? = nil - // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2ErrorMessage? { let code = pigeonVar_list[0] as! Int64 @@ -590,7 +595,8 @@ struct SK2ErrorMessage: Hashable { ] } static func == (lhs: SK2ErrorMessage, rhs: SK2ErrorMessage) -> Bool { - return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) } + return deepEqualsStoreKit2Messages(lhs.toList(), rhs.toList()) + } func hash(into hasher: inout Hasher) { deepHashStoreKit2Messages(value: toList(), hasher: &hasher) } @@ -728,19 +734,25 @@ private class StoreKit2MessagesPigeonCodecReaderWriter: FlutterStandardReaderWri } class StoreKit2MessagesPigeonCodec: FlutterStandardMessageCodec, @unchecked Sendable { - static let shared = StoreKit2MessagesPigeonCodec(readerWriter: StoreKit2MessagesPigeonCodecReaderWriter()) + static let shared = StoreKit2MessagesPigeonCodec( + readerWriter: StoreKit2MessagesPigeonCodecReaderWriter()) } - /// Generated protocol from Pigeon that represents a handler of messages from Flutter. protocol InAppPurchase2API { func canMakePayments() throws -> Bool - func products(identifiers: [String], completion: @escaping (Result<[SK2ProductMessage], Error>) -> Void) - func purchase(id: String, options: SK2ProductPurchaseOptionsMessage?, completion: @escaping (Result) -> Void) - func isWinBackOfferEligible(productId: String, offerId: String, completion: @escaping (Result) -> Void) - func isIntroductoryOfferEligible(productId: String, completion: @escaping (Result) -> Void) + func products( + identifiers: [String], completion: @escaping (Result<[SK2ProductMessage], Error>) -> Void) + func purchase( + id: String, options: SK2ProductPurchaseOptionsMessage?, + completion: @escaping (Result) -> Void) + func isWinBackOfferEligible( + productId: String, offerId: String, completion: @escaping (Result) -> Void) + func isIntroductoryOfferEligible( + productId: String, completion: @escaping (Result) -> Void) func transactions(completion: @escaping (Result<[SK2TransactionMessage], Error>) -> Void) - func unfinishedTransactions(completion: @escaping (Result<[SK2TransactionMessage], Error>) -> Void) + func unfinishedTransactions( + completion: @escaping (Result<[SK2TransactionMessage], Error>) -> Void) func finish(id: Int64, completion: @escaping (Result) -> Void) func startListeningToTransactions() throws func stopListeningToTransactions() throws @@ -754,9 +766,15 @@ protocol InAppPurchase2API { class InAppPurchase2APISetup { static var codec: FlutterStandardMessageCodec { StoreKit2MessagesPigeonCodec.shared } /// Sets up an instance of `InAppPurchase2API` to handle messages through the `binaryMessenger`. - static func setUp(binaryMessenger: FlutterBinaryMessenger, api: InAppPurchase2API?, messageChannelSuffix: String = "") { + static func setUp( + binaryMessenger: FlutterBinaryMessenger, api: InAppPurchase2API?, + messageChannelSuffix: String = "" + ) { let channelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : "" - let canMakePaymentsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.canMakePayments\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let canMakePaymentsChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.canMakePayments\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { canMakePaymentsChannel.setMessageHandler { _, reply in do { @@ -769,7 +787,10 @@ class InAppPurchase2APISetup { } else { canMakePaymentsChannel.setMessageHandler(nil) } - let productsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.products\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let productsChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.products\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { productsChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -786,7 +807,10 @@ class InAppPurchase2APISetup { } else { productsChannel.setMessageHandler(nil) } - let purchaseChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.purchase\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let purchaseChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.purchase\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { purchaseChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -804,7 +828,10 @@ class InAppPurchase2APISetup { } else { purchaseChannel.setMessageHandler(nil) } - let isWinBackOfferEligibleChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.isWinBackOfferEligible\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let isWinBackOfferEligibleChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.isWinBackOfferEligible\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { isWinBackOfferEligibleChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -822,7 +849,10 @@ class InAppPurchase2APISetup { } else { isWinBackOfferEligibleChannel.setMessageHandler(nil) } - let isIntroductoryOfferEligibleChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.isIntroductoryOfferEligible\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let isIntroductoryOfferEligibleChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.isIntroductoryOfferEligible\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { isIntroductoryOfferEligibleChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -839,7 +869,10 @@ class InAppPurchase2APISetup { } else { isIntroductoryOfferEligibleChannel.setMessageHandler(nil) } - let transactionsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.transactions\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let transactionsChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.transactions\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { transactionsChannel.setMessageHandler { _, reply in api.transactions { result in @@ -854,7 +887,10 @@ class InAppPurchase2APISetup { } else { transactionsChannel.setMessageHandler(nil) } - let unfinishedTransactionsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.unfinishedTransactions\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let unfinishedTransactionsChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.unfinishedTransactions\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { unfinishedTransactionsChannel.setMessageHandler { _, reply in api.unfinishedTransactions { result in @@ -869,7 +905,9 @@ class InAppPurchase2APISetup { } else { unfinishedTransactionsChannel.setMessageHandler(nil) } - let finishChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.finish\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let finishChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.finish\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { finishChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -886,7 +924,10 @@ class InAppPurchase2APISetup { } else { finishChannel.setMessageHandler(nil) } - let startListeningToTransactionsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.startListeningToTransactions\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let startListeningToTransactionsChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.startListeningToTransactions\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { startListeningToTransactionsChannel.setMessageHandler { _, reply in do { @@ -899,7 +940,10 @@ class InAppPurchase2APISetup { } else { startListeningToTransactionsChannel.setMessageHandler(nil) } - let stopListeningToTransactionsChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.stopListeningToTransactions\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let stopListeningToTransactionsChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.stopListeningToTransactions\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { stopListeningToTransactionsChannel.setMessageHandler { _, reply in do { @@ -912,7 +956,10 @@ class InAppPurchase2APISetup { } else { stopListeningToTransactionsChannel.setMessageHandler(nil) } - let restorePurchasesChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.restorePurchases\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let restorePurchasesChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.restorePurchases\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { restorePurchasesChannel.setMessageHandler { _, reply in api.restorePurchases { result in @@ -927,7 +974,10 @@ class InAppPurchase2APISetup { } else { restorePurchasesChannel.setMessageHandler(nil) } - let countryCodeChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.countryCode\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let countryCodeChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.countryCode\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { countryCodeChannel.setMessageHandler { _, reply in api.countryCode { result in @@ -942,7 +992,9 @@ class InAppPurchase2APISetup { } else { countryCodeChannel.setMessageHandler(nil) } - let syncChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.sync\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let syncChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.sync\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { syncChannel.setMessageHandler { _, reply in api.sync { result in @@ -957,7 +1009,10 @@ class InAppPurchase2APISetup { } else { syncChannel.setMessageHandler(nil) } - let presentOfferCodeRedeemSheetChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.presentOfferCodeRedeemSheet\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let presentOfferCodeRedeemSheetChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.presentOfferCodeRedeemSheet\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { presentOfferCodeRedeemSheetChannel.setMessageHandler { _, reply in api.presentOfferCodeRedeemSheet { result in @@ -976,7 +1031,9 @@ class InAppPurchase2APISetup { } /// Generated protocol from Pigeon that represents Flutter messages that can be called from Swift. protocol InAppPurchase2CallbackAPIProtocol { - func onTransactionsUpdated(newTransactions newTransactionsArg: [SK2TransactionMessage], completion: @escaping (Result) -> Void) + func onTransactionsUpdated( + newTransactions newTransactionsArg: [SK2TransactionMessage], + completion: @escaping (Result) -> Void) } class InAppPurchase2CallbackAPI: InAppPurchase2CallbackAPIProtocol { private let binaryMessenger: FlutterBinaryMessenger @@ -988,9 +1045,14 @@ class InAppPurchase2CallbackAPI: InAppPurchase2CallbackAPIProtocol { var codec: StoreKit2MessagesPigeonCodec { return StoreKit2MessagesPigeonCodec.shared } - func onTransactionsUpdated(newTransactions newTransactionsArg: [SK2TransactionMessage], completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2CallbackAPI.onTransactionsUpdated\(messageChannelSuffix)" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func onTransactionsUpdated( + newTransactions newTransactionsArg: [SK2TransactionMessage], + completion: @escaping (Result) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2CallbackAPI.onTransactionsUpdated\(messageChannelSuffix)" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([newTransactionsArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { completion(.failure(createConnectionError(withChannelName: channelName))) diff --git a/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit_objc/messages.g.m b/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit_objc/messages.g.m index 7be9e75eb517..ae7ef1937a2e 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit_objc/messages.g.m +++ b/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit_objc/messages.g.m @@ -733,11 +733,11 @@ void SetUpFIAInAppPurchaseAPIWithSuffix(id binaryMesseng binaryMessenger:binaryMessenger codec:FIAGetMessagesCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(startProductRequestProductIdentifiers: - completion:)], - @"FIAInAppPurchaseAPI api (%@) doesn't respond to " - @"@selector(startProductRequestProductIdentifiers:completion:)", - api); + NSCAssert( + [api respondsToSelector:@selector(startProductRequestProductIdentifiers:completion:)], + @"FIAInAppPurchaseAPI api (%@) doesn't respond to " + @"@selector(startProductRequestProductIdentifiers:completion:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSArray *arg_productIdentifiers = GetNullableObjectAtIndex(args, 0); diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner.xcodeproj/project.pbxproj b/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner.xcodeproj/project.pbxproj index 72a472ca29cd..11f178ac0301 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 60; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner/AppDelegate.m b/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner/AppDelegate.m index b416e30b601b..27b4d252c26f 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner/AppDelegate.m +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner/AppDelegate.m @@ -13,7 +13,7 @@ - (BOOL)application:(UIApplication *)application return [super application:application didFinishLaunchingWithOptions:launchOptions]; } -- (void)didInitializeImplicitFlutterEngine:(NSObject*)engineBridge { +- (void)didInitializeImplicitFlutterEngine:(NSObject *)engineBridge { [GeneratedPluginRegistrant registerWithRegistry:engineBridge.pluginRegistry]; } diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/lib/main.dart b/packages/in_app_purchase/in_app_purchase_storekit/example/lib/main.dart index 99c09e888790..090d31ffb5cd 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/lib/main.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/lib/main.dart @@ -445,7 +445,8 @@ class _MyAppState extends State<_MyApp> { backgroundColor: Theme.of(context).colorScheme.primary, foregroundColor: Colors.white, ), - onPressed: () => _iapStoreKitPlatformAddition.presentCodeRedemptionSheet(), + onPressed: () => + _iapStoreKitPlatformAddition.presentCodeRedemptionSheet(), child: const Text('Show code redemption sheet'), ), ], diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/macos/Runner.xcodeproj/project.pbxproj b/packages/in_app_purchase/in_app_purchase_storekit/example/macos/Runner.xcodeproj/project.pbxproj index 4676c5faa3c0..3db40419b6af 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/macos/Runner.xcodeproj/project.pbxproj +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/macos/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 60; + objectVersion = 54; objects = { /* Begin PBXAggregateTarget section */ diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift b/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift index 5b6de44d82ee..523d5fb3e78f 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/InAppPurchaseStoreKit2PluginTests.swift @@ -533,7 +533,8 @@ final class InAppPurchase2PluginTests: XCTestCase { @available(iOS 16.0, macOS 15.0, *) func testRedeemCodeSheetFailsGracefullyWhenNoWindow() { - let expectation = self.expectation(description: "Should fail gracefully when without key window") + let expectation = self.expectation( + description: "Should fail gracefully when without key window") plugin.registrar = nil diff --git a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/sk2_pigeon.g.dart b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/sk2_pigeon.g.dart index 41555274daaa..7eef14ba720c 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/sk2_pigeon.g.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/sk2_pigeon.g.dart @@ -12,9 +12,9 @@ import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; import 'package:flutter/services.dart'; Object? _extractReplyValueOrThrow( - List? replyList, - String channelName, { - required bool isNullValid, + List? replyList, + String channelName, { + required bool isNullValid, }) { if (replyList == null) { throw PlatformException( @@ -36,8 +36,11 @@ Object? _extractReplyValueOrThrow( return replyList.firstOrNull; } - -List wrapResponse({Object? result, PlatformException? error, bool empty = false}) { +List wrapResponse({ + Object? result, + PlatformException? error, + bool empty = false, +}) { if (empty) { return []; } @@ -46,37 +49,40 @@ List wrapResponse({Object? result, PlatformException? error, bool empty } return [error.code, error.message, error.details]; } + bool _deepEquals(Object? a, Object? b) { if (a is List && b is List) { return a.length == b.length && - a.indexed - .every(((int, dynamic) item) => _deepEquals(item.$2, b[item.$1])); + a.indexed.every( + ((int, dynamic) item) => _deepEquals(item.$2, b[item.$1]), + ); } if (a is Map && b is Map) { - return a.length == b.length && a.entries.every((MapEntry entry) => - (b as Map).containsKey(entry.key) && - _deepEquals(entry.value, b[entry.key])); + return a.length == b.length && + a.entries.every( + (MapEntry entry) => + (b as Map).containsKey(entry.key) && + _deepEquals(entry.value, b[entry.key]), + ); } return a == b; } - enum SK2ProductTypeMessage { /// A consumable in-app purchase. consumable, + /// A non-consumable in-app purchase. nonConsumable, + /// A non-renewing subscription. nonRenewable, + /// An auto-renewable subscription. autoRenewable, } -enum SK2SubscriptionOfferTypeMessage { - introductory, - promotional, - winBack, -} +enum SK2SubscriptionOfferTypeMessage { introductory, promotional, winBack } enum SK2SubscriptionOfferPaymentModeMessage { payAsYouGo, @@ -84,12 +90,7 @@ enum SK2SubscriptionOfferPaymentModeMessage { freeTrial, } -enum SK2SubscriptionPeriodUnitMessage { - day, - week, - month, - year, -} +enum SK2SubscriptionPeriodUnitMessage { day, week, month, year } enum SK2ProductPurchaseResultMessage { success, @@ -103,10 +104,13 @@ enum SK2ProductPurchaseResultMessage { enum SK2PurchaseStatusMessage { /// Purchase completed successfully. purchased, + /// Purchase is pending (e.g., Ask to Buy). pending, + /// Purchase was cancelled by the user. cancelled, + /// Purchase was restored. restored, } @@ -134,18 +138,12 @@ class SK2SubscriptionOfferMessage { SK2SubscriptionOfferPaymentModeMessage paymentMode; List _toList() { - return [ - id, - price, - type, - period, - periodCount, - paymentMode, - ]; + return [id, price, type, period, periodCount, paymentMode]; } Object encode() { - return _toList(); } + return _toList(); + } static SK2SubscriptionOfferMessage decode(Object result) { result as List; @@ -162,7 +160,8 @@ class SK2SubscriptionOfferMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes bool operator ==(Object other) { - if (other is! SK2SubscriptionOfferMessage || other.runtimeType != runtimeType) { + if (other is! SK2SubscriptionOfferMessage || + other.runtimeType != runtimeType) { return false; } if (identical(this, other)) { @@ -173,15 +172,11 @@ class SK2SubscriptionOfferMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()) -; + int get hashCode => Object.hashAll(_toList()); } class SK2SubscriptionPeriodMessage { - SK2SubscriptionPeriodMessage({ - required this.value, - required this.unit, - }); + SK2SubscriptionPeriodMessage({required this.value, required this.unit}); /// The number of units that the period represents. int value; @@ -190,14 +185,12 @@ class SK2SubscriptionPeriodMessage { SK2SubscriptionPeriodUnitMessage unit; List _toList() { - return [ - value, - unit, - ]; + return [value, unit]; } Object encode() { - return _toList(); } + return _toList(); + } static SK2SubscriptionPeriodMessage decode(Object result) { result as List; @@ -210,7 +203,8 @@ class SK2SubscriptionPeriodMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes bool operator ==(Object other) { - if (other is! SK2SubscriptionPeriodMessage || other.runtimeType != runtimeType) { + if (other is! SK2SubscriptionPeriodMessage || + other.runtimeType != runtimeType) { return false; } if (identical(this, other)) { @@ -221,8 +215,7 @@ class SK2SubscriptionPeriodMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()) -; + int get hashCode => Object.hashAll(_toList()); } class SK2SubscriptionInfoMessage { @@ -250,12 +243,14 @@ class SK2SubscriptionInfoMessage { } Object encode() { - return _toList(); } + return _toList(); + } static SK2SubscriptionInfoMessage decode(Object result) { result as List; return SK2SubscriptionInfoMessage( - promotionalOffers: (result[0] as List?)!.cast(), + promotionalOffers: (result[0] as List?)! + .cast(), subscriptionGroupID: result[1]! as String, subscriptionPeriod: result[2]! as SK2SubscriptionPeriodMessage, ); @@ -264,7 +259,8 @@ class SK2SubscriptionInfoMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes bool operator ==(Object other) { - if (other is! SK2SubscriptionInfoMessage || other.runtimeType != runtimeType) { + if (other is! SK2SubscriptionInfoMessage || + other.runtimeType != runtimeType) { return false; } if (identical(this, other)) { @@ -275,8 +271,7 @@ class SK2SubscriptionInfoMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()) -; + int get hashCode => Object.hashAll(_toList()); } /// A Pigeon message class representing a Product @@ -331,7 +326,8 @@ class SK2ProductMessage { } Object encode() { - return _toList(); } + return _toList(); + } static SK2ProductMessage decode(Object result) { result as List; @@ -361,8 +357,7 @@ class SK2ProductMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()) -; + int get hashCode => Object.hashAll(_toList()); } class SK2PriceLocaleMessage { @@ -376,14 +371,12 @@ class SK2PriceLocaleMessage { String currencySymbol; List _toList() { - return [ - currencyCode, - currencySymbol, - ]; + return [currencyCode, currencySymbol]; } Object encode() { - return _toList(); } + return _toList(); + } static SK2PriceLocaleMessage decode(Object result) { result as List; @@ -407,8 +400,7 @@ class SK2PriceLocaleMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()) -; + int get hashCode => Object.hashAll(_toList()); } /// A Pigeon message class representing a Signature @@ -430,16 +422,12 @@ class SK2SubscriptionOfferSignatureMessage { String signature; List _toList() { - return [ - keyID, - nonce, - timestamp, - signature, - ]; + return [keyID, nonce, timestamp, signature]; } Object encode() { - return _toList(); } + return _toList(); + } static SK2SubscriptionOfferSignatureMessage decode(Object result) { result as List; @@ -454,7 +442,8 @@ class SK2SubscriptionOfferSignatureMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes bool operator ==(Object other) { - if (other is! SK2SubscriptionOfferSignatureMessage || other.runtimeType != runtimeType) { + if (other is! SK2SubscriptionOfferSignatureMessage || + other.runtimeType != runtimeType) { return false; } if (identical(this, other)) { @@ -465,8 +454,7 @@ class SK2SubscriptionOfferSignatureMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()) -; + int get hashCode => Object.hashAll(_toList()); } class SK2SubscriptionOfferPurchaseMessage { @@ -480,27 +468,27 @@ class SK2SubscriptionOfferPurchaseMessage { SK2SubscriptionOfferSignatureMessage promotionalOfferSignature; List _toList() { - return [ - promotionalOfferId, - promotionalOfferSignature, - ]; + return [promotionalOfferId, promotionalOfferSignature]; } Object encode() { - return _toList(); } + return _toList(); + } static SK2SubscriptionOfferPurchaseMessage decode(Object result) { result as List; return SK2SubscriptionOfferPurchaseMessage( promotionalOfferId: result[0]! as String, - promotionalOfferSignature: result[1]! as SK2SubscriptionOfferSignatureMessage, + promotionalOfferSignature: + result[1]! as SK2SubscriptionOfferSignatureMessage, ); } @override // ignore: avoid_equals_and_hash_code_on_mutable_classes bool operator ==(Object other) { - if (other is! SK2SubscriptionOfferPurchaseMessage || other.runtimeType != runtimeType) { + if (other is! SK2SubscriptionOfferPurchaseMessage || + other.runtimeType != runtimeType) { return false; } if (identical(this, other)) { @@ -511,8 +499,7 @@ class SK2SubscriptionOfferPurchaseMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()) -; + int get hashCode => Object.hashAll(_toList()); } class SK2ProductPurchaseOptionsMessage { @@ -541,7 +528,8 @@ class SK2ProductPurchaseOptionsMessage { } Object encode() { - return _toList(); } + return _toList(); + } static SK2ProductPurchaseOptionsMessage decode(Object result) { result as List; @@ -556,7 +544,8 @@ class SK2ProductPurchaseOptionsMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes bool operator ==(Object other) { - if (other is! SK2ProductPurchaseOptionsMessage || other.runtimeType != runtimeType) { + if (other is! SK2ProductPurchaseOptionsMessage || + other.runtimeType != runtimeType) { return false; } if (identical(this, other)) { @@ -567,8 +556,7 @@ class SK2ProductPurchaseOptionsMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()) -; + int get hashCode => Object.hashAll(_toList()); } class SK2TransactionMessage { @@ -627,7 +615,8 @@ class SK2TransactionMessage { } Object encode() { - return _toList(); } + return _toList(); + } static SK2TransactionMessage decode(Object result) { result as List; @@ -660,16 +649,11 @@ class SK2TransactionMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()) -; + int get hashCode => Object.hashAll(_toList()); } class SK2ErrorMessage { - SK2ErrorMessage({ - required this.code, - required this.domain, - this.userInfo, - }); + SK2ErrorMessage({required this.code, required this.domain, this.userInfo}); int code; @@ -678,15 +662,12 @@ class SK2ErrorMessage { Map? userInfo; List _toList() { - return [ - code, - domain, - userInfo, - ]; + return [code, domain, userInfo]; } Object encode() { - return _toList(); } + return _toList(); + } static SK2ErrorMessage decode(Object result) { result as List; @@ -711,11 +692,9 @@ class SK2ErrorMessage { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()) -; + int get hashCode => Object.hashAll(_toList()); } - class _PigeonCodec extends StandardMessageCodec { const _PigeonCodec(); @override @@ -723,52 +702,52 @@ class _PigeonCodec extends StandardMessageCodec { if (value is int) { buffer.putUint8(4); buffer.putInt64(value); - } else if (value is SK2ProductTypeMessage) { + } else if (value is SK2ProductTypeMessage) { buffer.putUint8(129); writeValue(buffer, value.index); - } else if (value is SK2SubscriptionOfferTypeMessage) { + } else if (value is SK2SubscriptionOfferTypeMessage) { buffer.putUint8(130); writeValue(buffer, value.index); - } else if (value is SK2SubscriptionOfferPaymentModeMessage) { + } else if (value is SK2SubscriptionOfferPaymentModeMessage) { buffer.putUint8(131); writeValue(buffer, value.index); - } else if (value is SK2SubscriptionPeriodUnitMessage) { + } else if (value is SK2SubscriptionPeriodUnitMessage) { buffer.putUint8(132); writeValue(buffer, value.index); - } else if (value is SK2ProductPurchaseResultMessage) { + } else if (value is SK2ProductPurchaseResultMessage) { buffer.putUint8(133); writeValue(buffer, value.index); - } else if (value is SK2PurchaseStatusMessage) { + } else if (value is SK2PurchaseStatusMessage) { buffer.putUint8(134); writeValue(buffer, value.index); - } else if (value is SK2SubscriptionOfferMessage) { + } else if (value is SK2SubscriptionOfferMessage) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else if (value is SK2SubscriptionPeriodMessage) { + } else if (value is SK2SubscriptionPeriodMessage) { buffer.putUint8(136); writeValue(buffer, value.encode()); - } else if (value is SK2SubscriptionInfoMessage) { + } else if (value is SK2SubscriptionInfoMessage) { buffer.putUint8(137); writeValue(buffer, value.encode()); - } else if (value is SK2ProductMessage) { + } else if (value is SK2ProductMessage) { buffer.putUint8(138); writeValue(buffer, value.encode()); - } else if (value is SK2PriceLocaleMessage) { + } else if (value is SK2PriceLocaleMessage) { buffer.putUint8(139); writeValue(buffer, value.encode()); - } else if (value is SK2SubscriptionOfferSignatureMessage) { + } else if (value is SK2SubscriptionOfferSignatureMessage) { buffer.putUint8(140); writeValue(buffer, value.encode()); - } else if (value is SK2SubscriptionOfferPurchaseMessage) { + } else if (value is SK2SubscriptionOfferPurchaseMessage) { buffer.putUint8(141); writeValue(buffer, value.encode()); - } else if (value is SK2ProductPurchaseOptionsMessage) { + } else if (value is SK2ProductPurchaseOptionsMessage) { buffer.putUint8(142); writeValue(buffer, value.encode()); - } else if (value is SK2TransactionMessage) { + } else if (value is SK2TransactionMessage) { buffer.putUint8(143); writeValue(buffer, value.encode()); - } else if (value is SK2ErrorMessage) { + } else if (value is SK2ErrorMessage) { buffer.putUint8(144); writeValue(buffer, value.encode()); } else { @@ -784,16 +763,24 @@ class _PigeonCodec extends StandardMessageCodec { return value == null ? null : SK2ProductTypeMessage.values[value]; case 130: final value = readValue(buffer) as int?; - return value == null ? null : SK2SubscriptionOfferTypeMessage.values[value]; + return value == null + ? null + : SK2SubscriptionOfferTypeMessage.values[value]; case 131: final value = readValue(buffer) as int?; - return value == null ? null : SK2SubscriptionOfferPaymentModeMessage.values[value]; + return value == null + ? null + : SK2SubscriptionOfferPaymentModeMessage.values[value]; case 132: final value = readValue(buffer) as int?; - return value == null ? null : SK2SubscriptionPeriodUnitMessage.values[value]; + return value == null + ? null + : SK2SubscriptionPeriodUnitMessage.values[value]; case 133: final value = readValue(buffer) as int?; - return value == null ? null : SK2ProductPurchaseResultMessage.values[value]; + return value == null + ? null + : SK2ProductPurchaseResultMessage.values[value]; case 134: final value = readValue(buffer) as int?; return value == null ? null : SK2PurchaseStatusMessage.values[value]; @@ -827,9 +814,13 @@ class InAppPurchase2API { /// Constructor for [InAppPurchase2API]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - InAppPurchase2API({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) - : pigeonVar_binaryMessenger = binaryMessenger, - pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + InAppPurchase2API({ + BinaryMessenger? binaryMessenger, + String messageChannelSuffix = '', + }) : pigeonVar_binaryMessenger = binaryMessenger, + pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty + ? '.$messageChannelSuffix' + : ''; final BinaryMessenger? pigeonVar_binaryMessenger; static const MessageCodec pigeonChannelCodec = _PigeonCodec(); @@ -837,7 +828,8 @@ class InAppPurchase2API { final String pigeonVar_messageChannelSuffix; Future canMakePayments() async { - final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.canMakePayments$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.canMakePayments$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -847,92 +839,103 @@ class InAppPurchase2API { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; final Object pigeonVar_replyValue = _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: false, - ) - !; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + )!; return pigeonVar_replyValue as bool; } Future> products(List identifiers) async { - final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.products$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.products$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([identifiers]); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [identifiers], + ); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; final Object pigeonVar_replyValue = _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: false, - ) - !; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + )!; return (pigeonVar_replyValue as List).cast(); } - Future purchase(String id, {SK2ProductPurchaseOptionsMessage? options}) async { - final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.purchase$pigeonVar_messageChannelSuffix'; + Future purchase( + String id, { + SK2ProductPurchaseOptionsMessage? options, + }) async { + final pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.purchase$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([id, options]); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [id, options], + ); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; final Object pigeonVar_replyValue = _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: false, - ) - !; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + )!; return pigeonVar_replyValue as SK2ProductPurchaseResultMessage; } Future isWinBackOfferEligible(String productId, String offerId) async { - final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.isWinBackOfferEligible$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.isWinBackOfferEligible$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([productId, offerId]); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [productId, offerId], + ); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; final Object pigeonVar_replyValue = _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: false, - ) - !; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + )!; return pigeonVar_replyValue as bool; } Future isIntroductoryOfferEligible(String productId) async { - final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.isIntroductoryOfferEligible$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.isIntroductoryOfferEligible$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([productId]); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [productId], + ); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; final Object pigeonVar_replyValue = _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: false, - ) - !; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + )!; return pigeonVar_replyValue as bool; } Future> transactions() async { - final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.transactions$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.transactions$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -942,16 +945,17 @@ class InAppPurchase2API { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; final Object pigeonVar_replyValue = _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: false, - ) - !; - return (pigeonVar_replyValue as List).cast(); + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + )!; + return (pigeonVar_replyValue as List) + .cast(); } Future> unfinishedTransactions() async { - final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.unfinishedTransactions$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.unfinishedTransactions$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -961,34 +965,37 @@ class InAppPurchase2API { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; final Object pigeonVar_replyValue = _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: false, - ) - !; - return (pigeonVar_replyValue as List).cast(); + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + )!; + return (pigeonVar_replyValue as List) + .cast(); } Future finish(int id) async { - final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.finish$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.finish$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([id]); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [id], + ); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } Future startListeningToTransactions() async { - final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.startListeningToTransactions$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.startListeningToTransactions$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -998,15 +1005,15 @@ class InAppPurchase2API { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } Future stopListeningToTransactions() async { - final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.stopListeningToTransactions$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.stopListeningToTransactions$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -1016,15 +1023,15 @@ class InAppPurchase2API { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } Future restorePurchases() async { - final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.restorePurchases$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.restorePurchases$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -1034,15 +1041,15 @@ class InAppPurchase2API { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } Future countryCode() async { - final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.countryCode$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.countryCode$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -1052,16 +1059,16 @@ class InAppPurchase2API { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; final Object pigeonVar_replyValue = _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: false, - ) - !; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + )!; return pigeonVar_replyValue as String; } Future sync() async { - final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.sync$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.sync$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -1071,15 +1078,15 @@ class InAppPurchase2API { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } Future presentOfferCodeRedeemSheet() async { - final pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.presentOfferCodeRedeemSheet$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.presentOfferCodeRedeemSheet$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -1089,11 +1096,10 @@ class InAppPurchase2API { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } } @@ -1102,29 +1108,44 @@ abstract class InAppPurchase2CallbackAPI { void onTransactionsUpdated(List newTransactions); - static void setUp(InAppPurchase2CallbackAPI? api, {BinaryMessenger? binaryMessenger, String messageChannelSuffix = '',}) { - messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + static void setUp( + InAppPurchase2CallbackAPI? api, { + BinaryMessenger? binaryMessenger, + String messageChannelSuffix = '', + }) { + messageChannelSuffix = messageChannelSuffix.isNotEmpty + ? '.$messageChannelSuffix' + : ''; { final pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2CallbackAPI.onTransactionsUpdated$messageChannelSuffix', pigeonChannelCodec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2CallbackAPI.onTransactionsUpdated$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2CallbackAPI.onTransactionsUpdated was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2CallbackAPI.onTransactionsUpdated was null.', + ); final List args = (message as List?)!; - final List? arg_newTransactions = (args[0] as List?)?.cast(); - assert(arg_newTransactions != null, - 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2CallbackAPI.onTransactionsUpdated was null, expected non-null List.'); + final List? arg_newTransactions = + (args[0] as List?)?.cast(); + assert( + arg_newTransactions != null, + 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2CallbackAPI.onTransactionsUpdated was null, expected non-null List.', + ); try { api.onTransactionsUpdated(arg_newTransactions!); return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString()), + ); } }); }