diff --git a/packages/in_app_purchase/in_app_purchase_storekit/CHANGELOG.md b/packages/in_app_purchase/in_app_purchase_storekit/CHANGELOG.md index 3d4cc8d98378..35312c338889 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/CHANGELOG.md +++ b/packages/in_app_purchase/in_app_purchase_storekit/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.20+1 + +* Disallow enabling StoreKit2 on devices below iOS 15, or OSX 15. + ## 0.3.20 * Fixes manual invocation of `finishTransaction` causing a fatal crash. diff --git a/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/InAppPurchasePlugin.swift b/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/InAppPurchasePlugin.swift index 8954f2f46b13..cd9c8221e1fe 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/InAppPurchasePlugin.swift +++ b/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/InAppPurchasePlugin.swift @@ -420,6 +420,16 @@ public class InAppPurchasePlugin: NSObject, FlutterPlugin, FIAInAppPurchaseAPI { NSLog("Received an updatedDownloads callback, but downloads are not supported.") } + public func supportsStoreKit2WithError(_ error: AutoreleasingUnsafeMutablePointer) + -> NSNumber? + { + if #available(iOS 15, macOS 15, *) { + return true + } + NSLog("This device does not support StoreKit2. Falling back to the original StoreKit.") + return false + } + // MARK: - Methods exposed for testing func getProduct(productID: String) -> SKProduct? { return self.productsCache[productID] as? SKProduct diff --git a/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/StoreKit2/sk2_pigeon.g.swift b/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/StoreKit2/sk2_pigeon.g.swift index c6923001143f..91da2552b0ab 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/StoreKit2/sk2_pigeon.g.swift +++ b/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/StoreKit2/sk2_pigeon.g.swift @@ -29,7 +29,7 @@ final class PigeonError: Error { var localizedDescription: String { return "PigeonError(code: \(code), message: \(message ?? ""), details: \(details ?? "")" - } + } } private func wrapResult(_ result: Any?) -> [Any?] { @@ -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 { @@ -117,6 +115,8 @@ struct SK2SubscriptionOfferMessage { var periodCount: Int64 var paymentMode: SK2SubscriptionOfferPaymentModeMessage + + // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2SubscriptionOfferMessage? { let id: String? = nilOrValue(pigeonVar_list[0]) @@ -154,6 +154,8 @@ struct SK2SubscriptionPeriodMessage { /// 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 @@ -181,6 +183,8 @@ struct SK2SubscriptionInfoMessage { /// 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] @@ -224,6 +228,8 @@ struct SK2ProductMessage { /// 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 @@ -265,6 +271,8 @@ struct SK2PriceLocaleMessage { var currencyCode: String var currencySymbol: String + + // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2PriceLocaleMessage? { let currencyCode = pigeonVar_list[0] as! String @@ -288,6 +296,8 @@ struct SK2ProductPurchaseOptionsMessage { var appAccountToken: String? = nil var quantity: Int64? = nil + + // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2ProductPurchaseOptionsMessage? { let appAccountToken: String? = nilOrValue(pigeonVar_list[0]) @@ -319,6 +329,8 @@ struct SK2TransactionMessage { var receiptData: String? = nil var error: SK2ErrorMessage? = nil + + // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2TransactionMessage? { let id = pigeonVar_list[0] as! Int64 @@ -367,6 +379,8 @@ struct SK2ErrorMessage { 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 @@ -504,34 +518,27 @@ class sk2_pigeonPigeonCodec: FlutterStandardMessageCodec, @unchecked Sendable { static let shared = sk2_pigeonPigeonCodec(readerWriter: sk2_pigeonPigeonCodecReaderWriter()) } + /// 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 products(identifiers: [String], completion: @escaping (Result<[SK2ProductMessage], Error>) -> Void) + func purchase(id: String, options: SK2ProductPurchaseOptionsMessage?, completion: @escaping (Result) -> Void) func transactions(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 supportsStoreKit2() throws -> Bool } /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. class InAppPurchase2APISetup { static var codec: FlutterStandardMessageCodec { sk2_pigeonPigeonCodec.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 { @@ -544,10 +551,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?] @@ -564,10 +568,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?] @@ -585,10 +586,7 @@ class InAppPurchase2APISetup { } else { purchaseChannel.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 @@ -603,9 +601,7 @@ class InAppPurchase2APISetup { } else { transactionsChannel.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?] @@ -622,10 +618,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 { @@ -638,10 +631,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 { @@ -654,10 +644,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 @@ -672,13 +659,24 @@ class InAppPurchase2APISetup { } else { restorePurchasesChannel.setMessageHandler(nil) } + let supportsStoreKit2Channel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.supportsStoreKit2\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + if let api = api { + supportsStoreKit2Channel.setMessageHandler { _, reply in + do { + let result = try api.supportsStoreKit2() + reply(wrapResult(result)) + } catch { + reply(wrapError(error)) + } + } + } else { + supportsStoreKit2Channel.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 @@ -690,14 +688,9 @@ class InAppPurchase2CallbackAPI: InAppPurchase2CallbackAPIProtocol { var codec: sk2_pigeonPigeonCodec { return sk2_pigeonPigeonCodec.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/Classes/messages.g.h b/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/messages.g.h index a6059f269d73..a56343cddea4 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/messages.g.h +++ b/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/messages.g.h @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v22.4.2), do not edit directly. +// Autogenerated from Pigeon (v22.6.0), do not edit directly. // See also: https://pub.dev/packages/pigeon #import @@ -67,8 +67,7 @@ typedef NS_ENUM(NSUInteger, FIASKProductDiscountTypeMessage) { typedef NS_ENUM(NSUInteger, FIASKProductDiscountPaymentModeMessage) { /// Allows user to pay the discounted price at each payment period. FIASKProductDiscountPaymentModeMessagePayAsYouGo = 0, - /// Allows user to pay the discounted price upfront and receive the product for the rest of time - /// that was paid for. + /// Allows user to pay the discounted price upfront and receive the product for the rest of time that was paid for. FIASKProductDiscountPaymentModeMessagePayUpFront = 1, /// User pays nothing during the discounted period. FIASKProductDiscountPaymentModeMessageFreeTrial = 2, @@ -110,140 +109,140 @@ typedef NS_ENUM(NSUInteger, FIASKSubscriptionPeriodUnitMessage) { /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithPayment:(FIASKPaymentMessage *)payment - transactionState:(FIASKPaymentTransactionStateMessage)transactionState - originalTransaction:(nullable FIASKPaymentTransactionMessage *)originalTransaction - transactionTimeStamp:(nullable NSNumber *)transactionTimeStamp - transactionIdentifier:(nullable NSString *)transactionIdentifier - error:(nullable FIASKErrorMessage *)error; -@property(nonatomic, strong) FIASKPaymentMessage *payment; + transactionState:(FIASKPaymentTransactionStateMessage)transactionState + originalTransaction:(nullable FIASKPaymentTransactionMessage *)originalTransaction + transactionTimeStamp:(nullable NSNumber *)transactionTimeStamp + transactionIdentifier:(nullable NSString *)transactionIdentifier + error:(nullable FIASKErrorMessage *)error; +@property(nonatomic, strong) FIASKPaymentMessage * payment; @property(nonatomic, assign) FIASKPaymentTransactionStateMessage transactionState; -@property(nonatomic, strong, nullable) FIASKPaymentTransactionMessage *originalTransaction; -@property(nonatomic, strong, nullable) NSNumber *transactionTimeStamp; -@property(nonatomic, copy, nullable) NSString *transactionIdentifier; -@property(nonatomic, strong, nullable) FIASKErrorMessage *error; +@property(nonatomic, strong, nullable) FIASKPaymentTransactionMessage * originalTransaction; +@property(nonatomic, strong, nullable) NSNumber * transactionTimeStamp; +@property(nonatomic, copy, nullable) NSString * transactionIdentifier; +@property(nonatomic, strong, nullable) FIASKErrorMessage * error; @end @interface FIASKPaymentMessage : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithProductIdentifier:(NSString *)productIdentifier - applicationUsername:(nullable NSString *)applicationUsername - requestData:(nullable NSString *)requestData - quantity:(NSInteger)quantity - simulatesAskToBuyInSandbox:(BOOL)simulatesAskToBuyInSandbox - paymentDiscount:(nullable FIASKPaymentDiscountMessage *)paymentDiscount; -@property(nonatomic, copy) NSString *productIdentifier; -@property(nonatomic, copy, nullable) NSString *applicationUsername; -@property(nonatomic, copy, nullable) NSString *requestData; -@property(nonatomic, assign) NSInteger quantity; -@property(nonatomic, assign) BOOL simulatesAskToBuyInSandbox; -@property(nonatomic, strong, nullable) FIASKPaymentDiscountMessage *paymentDiscount; + applicationUsername:(nullable NSString *)applicationUsername + requestData:(nullable NSString *)requestData + quantity:(NSInteger )quantity + simulatesAskToBuyInSandbox:(BOOL )simulatesAskToBuyInSandbox + paymentDiscount:(nullable FIASKPaymentDiscountMessage *)paymentDiscount; +@property(nonatomic, copy) NSString * productIdentifier; +@property(nonatomic, copy, nullable) NSString * applicationUsername; +@property(nonatomic, copy, nullable) NSString * requestData; +@property(nonatomic, assign) NSInteger quantity; +@property(nonatomic, assign) BOOL simulatesAskToBuyInSandbox; +@property(nonatomic, strong, nullable) FIASKPaymentDiscountMessage * paymentDiscount; @end @interface FIASKErrorMessage : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; -+ (instancetype)makeWithCode:(NSInteger)code - domain:(NSString *)domain - userInfo:(nullable NSDictionary *)userInfo; -@property(nonatomic, assign) NSInteger code; -@property(nonatomic, copy) NSString *domain; -@property(nonatomic, copy, nullable) NSDictionary *userInfo; ++ (instancetype)makeWithCode:(NSInteger )code + domain:(NSString *)domain + userInfo:(nullable NSDictionary *)userInfo; +@property(nonatomic, assign) NSInteger code; +@property(nonatomic, copy) NSString * domain; +@property(nonatomic, copy, nullable) NSDictionary * userInfo; @end @interface FIASKPaymentDiscountMessage : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithIdentifier:(NSString *)identifier - keyIdentifier:(NSString *)keyIdentifier - nonce:(NSString *)nonce - signature:(NSString *)signature - timestamp:(NSInteger)timestamp; -@property(nonatomic, copy) NSString *identifier; -@property(nonatomic, copy) NSString *keyIdentifier; -@property(nonatomic, copy) NSString *nonce; -@property(nonatomic, copy) NSString *signature; -@property(nonatomic, assign) NSInteger timestamp; + keyIdentifier:(NSString *)keyIdentifier + nonce:(NSString *)nonce + signature:(NSString *)signature + timestamp:(NSInteger )timestamp; +@property(nonatomic, copy) NSString * identifier; +@property(nonatomic, copy) NSString * keyIdentifier; +@property(nonatomic, copy) NSString * nonce; +@property(nonatomic, copy) NSString * signature; +@property(nonatomic, assign) NSInteger timestamp; @end @interface FIASKStorefrontMessage : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; -+ (instancetype)makeWithCountryCode:(NSString *)countryCode identifier:(NSString *)identifier; -@property(nonatomic, copy) NSString *countryCode; -@property(nonatomic, copy) NSString *identifier; ++ (instancetype)makeWithCountryCode:(NSString *)countryCode + identifier:(NSString *)identifier; +@property(nonatomic, copy) NSString * countryCode; +@property(nonatomic, copy) NSString * identifier; @end @interface FIASKProductsResponseMessage : NSObject + (instancetype)makeWithProducts:(nullable NSArray *)products - invalidProductIdentifiers:(nullable NSArray *)invalidProductIdentifiers; -@property(nonatomic, copy, nullable) NSArray *products; -@property(nonatomic, copy, nullable) NSArray *invalidProductIdentifiers; + invalidProductIdentifiers:(nullable NSArray *)invalidProductIdentifiers; +@property(nonatomic, copy, nullable) NSArray * products; +@property(nonatomic, copy, nullable) NSArray * invalidProductIdentifiers; @end @interface FIASKProductMessage : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; -+ (instancetype) - makeWithProductIdentifier:(NSString *)productIdentifier - localizedTitle:(NSString *)localizedTitle - localizedDescription:(nullable NSString *)localizedDescription - priceLocale:(FIASKPriceLocaleMessage *)priceLocale ++ (instancetype)makeWithProductIdentifier:(NSString *)productIdentifier + localizedTitle:(NSString *)localizedTitle + localizedDescription:(nullable NSString *)localizedDescription + priceLocale:(FIASKPriceLocaleMessage *)priceLocale subscriptionGroupIdentifier:(nullable NSString *)subscriptionGroupIdentifier - price:(NSString *)price - subscriptionPeriod:(nullable FIASKProductSubscriptionPeriodMessage *)subscriptionPeriod - introductoryPrice:(nullable FIASKProductDiscountMessage *)introductoryPrice - discounts:(nullable NSArray *)discounts; -@property(nonatomic, copy) NSString *productIdentifier; -@property(nonatomic, copy) NSString *localizedTitle; -@property(nonatomic, copy, nullable) NSString *localizedDescription; -@property(nonatomic, strong) FIASKPriceLocaleMessage *priceLocale; -@property(nonatomic, copy, nullable) NSString *subscriptionGroupIdentifier; -@property(nonatomic, copy) NSString *price; -@property(nonatomic, strong, nullable) FIASKProductSubscriptionPeriodMessage *subscriptionPeriod; -@property(nonatomic, strong, nullable) FIASKProductDiscountMessage *introductoryPrice; -@property(nonatomic, copy, nullable) NSArray *discounts; + price:(NSString *)price + subscriptionPeriod:(nullable FIASKProductSubscriptionPeriodMessage *)subscriptionPeriod + introductoryPrice:(nullable FIASKProductDiscountMessage *)introductoryPrice + discounts:(nullable NSArray *)discounts; +@property(nonatomic, copy) NSString * productIdentifier; +@property(nonatomic, copy) NSString * localizedTitle; +@property(nonatomic, copy, nullable) NSString * localizedDescription; +@property(nonatomic, strong) FIASKPriceLocaleMessage * priceLocale; +@property(nonatomic, copy, nullable) NSString * subscriptionGroupIdentifier; +@property(nonatomic, copy) NSString * price; +@property(nonatomic, strong, nullable) FIASKProductSubscriptionPeriodMessage * subscriptionPeriod; +@property(nonatomic, strong, nullable) FIASKProductDiscountMessage * introductoryPrice; +@property(nonatomic, copy, nullable) NSArray * discounts; @end @interface FIASKPriceLocaleMessage : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithCurrencySymbol:(NSString *)currencySymbol - currencyCode:(NSString *)currencyCode - countryCode:(NSString *)countryCode; -/// The currency symbol for the locale, e.g. $ for US locale. -@property(nonatomic, copy) NSString *currencySymbol; -/// The currency code for the locale, e.g. USD for US locale. -@property(nonatomic, copy) NSString *currencyCode; -/// The country code for the locale, e.g. US for US locale. -@property(nonatomic, copy) NSString *countryCode; + currencyCode:(NSString *)currencyCode + countryCode:(NSString *)countryCode; +///The currency symbol for the locale, e.g. $ for US locale. +@property(nonatomic, copy) NSString * currencySymbol; +///The currency code for the locale, e.g. USD for US locale. +@property(nonatomic, copy) NSString * currencyCode; +///The country code for the locale, e.g. US for US locale. +@property(nonatomic, copy) NSString * countryCode; @end @interface FIASKProductDiscountMessage : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithPrice:(NSString *)price - priceLocale:(FIASKPriceLocaleMessage *)priceLocale - numberOfPeriods:(NSInteger)numberOfPeriods - paymentMode:(FIASKProductDiscountPaymentModeMessage)paymentMode - subscriptionPeriod:(FIASKProductSubscriptionPeriodMessage *)subscriptionPeriod - identifier:(nullable NSString *)identifier - type:(FIASKProductDiscountTypeMessage)type; -@property(nonatomic, copy) NSString *price; -@property(nonatomic, strong) FIASKPriceLocaleMessage *priceLocale; -@property(nonatomic, assign) NSInteger numberOfPeriods; + priceLocale:(FIASKPriceLocaleMessage *)priceLocale + numberOfPeriods:(NSInteger )numberOfPeriods + paymentMode:(FIASKProductDiscountPaymentModeMessage)paymentMode + subscriptionPeriod:(FIASKProductSubscriptionPeriodMessage *)subscriptionPeriod + identifier:(nullable NSString *)identifier + type:(FIASKProductDiscountTypeMessage)type; +@property(nonatomic, copy) NSString * price; +@property(nonatomic, strong) FIASKPriceLocaleMessage * priceLocale; +@property(nonatomic, assign) NSInteger numberOfPeriods; @property(nonatomic, assign) FIASKProductDiscountPaymentModeMessage paymentMode; -@property(nonatomic, strong) FIASKProductSubscriptionPeriodMessage *subscriptionPeriod; -@property(nonatomic, copy, nullable) NSString *identifier; +@property(nonatomic, strong) FIASKProductSubscriptionPeriodMessage * subscriptionPeriod; +@property(nonatomic, copy, nullable) NSString * identifier; @property(nonatomic, assign) FIASKProductDiscountTypeMessage type; @end @interface FIASKProductSubscriptionPeriodMessage : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; -+ (instancetype)makeWithNumberOfUnits:(NSInteger)numberOfUnits - unit:(FIASKSubscriptionPeriodUnitMessage)unit; -@property(nonatomic, assign) NSInteger numberOfUnits; ++ (instancetype)makeWithNumberOfUnits:(NSInteger )numberOfUnits + unit:(FIASKSubscriptionPeriodUnitMessage)unit; +@property(nonatomic, assign) NSInteger numberOfUnits; @property(nonatomic, assign) FIASKSubscriptionPeriodUnitMessage unit; @end @@ -256,23 +255,16 @@ NSObject *FIAGetMessagesCodec(void); /// @return `nil` only when `error != nil`. - (nullable NSNumber *)canMakePaymentsWithError:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable NSArray *)transactionsWithError: - (FlutterError *_Nullable *_Nonnull)error; +- (nullable NSArray *)transactionsWithError:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. - (nullable FIASKStorefrontMessage *)storefrontWithError:(FlutterError *_Nullable *_Nonnull)error; -- (void)addPaymentPaymentMap:(NSDictionary *)paymentMap - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)startProductRequestProductIdentifiers:(NSArray *)productIdentifiers - completion:(void (^)(FIASKProductsResponseMessage *_Nullable, - FlutterError *_Nullable))completion; -- (void)finishTransactionFinishMap:(NSDictionary *)finishMap - error:(FlutterError *_Nullable *_Nonnull)error; -- (void)restoreTransactionsApplicationUserName:(nullable NSString *)applicationUserName - error:(FlutterError *_Nullable *_Nonnull)error; +- (void)addPaymentPaymentMap:(NSDictionary *)paymentMap error:(FlutterError *_Nullable *_Nonnull)error; +- (void)startProductRequestProductIdentifiers:(NSArray *)productIdentifiers completion:(void (^)(FIASKProductsResponseMessage *_Nullable, FlutterError *_Nullable))completion; +- (void)finishTransactionFinishMap:(NSDictionary *)finishMap error:(FlutterError *_Nullable *_Nonnull)error; +- (void)restoreTransactionsApplicationUserName:(nullable NSString *)applicationUserName error:(FlutterError *_Nullable *_Nonnull)error; - (void)presentCodeRedemptionSheetWithError:(FlutterError *_Nullable *_Nonnull)error; - (nullable NSString *)retrieveReceiptDataWithError:(FlutterError *_Nullable *_Nonnull)error; -- (void)refreshReceiptReceiptProperties:(nullable NSDictionary *)receiptProperties - completion:(void (^)(FlutterError *_Nullable))completion; +- (void)refreshReceiptReceiptProperties:(nullable NSDictionary *)receiptProperties completion:(void (^)(FlutterError *_Nullable))completion; - (void)startObservingPaymentQueueWithError:(FlutterError *_Nullable *_Nonnull)error; - (void)stopObservingPaymentQueueWithError:(FlutterError *_Nullable *_Nonnull)error; - (void)registerPaymentQueueDelegateWithError:(FlutterError *_Nullable *_Nonnull)error; @@ -280,11 +272,8 @@ NSObject *FIAGetMessagesCodec(void); - (void)showPriceConsentIfNeededWithError:(FlutterError *_Nullable *_Nonnull)error; @end -extern void SetUpFIAInAppPurchaseAPI(id binaryMessenger, - NSObject *_Nullable api); +extern void SetUpFIAInAppPurchaseAPI(id binaryMessenger, NSObject *_Nullable api); -extern void SetUpFIAInAppPurchaseAPIWithSuffix(id binaryMessenger, - NSObject *_Nullable api, - NSString *messageChannelSuffix); +extern void SetUpFIAInAppPurchaseAPIWithSuffix(id binaryMessenger, NSObject *_Nullable api, NSString *messageChannelSuffix); NS_ASSUME_NONNULL_END diff --git a/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/messages.g.m b/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/messages.g.m index 62988eb04fee..f9ab777b8e9e 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/messages.g.m +++ b/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/messages.g.m @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v22.4.2), do not edit directly. +// Autogenerated from Pigeon (v22.6.0), do not edit directly. // See also: https://pub.dev/packages/pigeon #import "messages.g.h" @@ -132,12 +132,12 @@ + (nullable FIASKProductSubscriptionPeriodMessage *)nullableFromList:(NSArray *)list { FIASKPaymentTransactionMessage *pigeonResult = [[FIASKPaymentTransactionMessage alloc] init]; pigeonResult.payment = GetNullableObjectAtIndex(list, 0); - FIASKPaymentTransactionStateMessageBox *boxedFIASKPaymentTransactionStateMessage = - GetNullableObjectAtIndex(list, 1); + FIASKPaymentTransactionStateMessageBox *boxedFIASKPaymentTransactionStateMessage = GetNullableObjectAtIndex(list, 1); pigeonResult.transactionState = boxedFIASKPaymentTransactionStateMessage.value; pigeonResult.originalTransaction = GetNullableObjectAtIndex(list, 2); pigeonResult.transactionTimeStamp = GetNullableObjectAtIndex(list, 3); @@ -175,12 +174,12 @@ + (nullable FIASKPaymentTransactionMessage *)nullableFromList:(NSArray *)lis @implementation FIASKPaymentMessage + (instancetype)makeWithProductIdentifier:(NSString *)productIdentifier - applicationUsername:(nullable NSString *)applicationUsername - requestData:(nullable NSString *)requestData - quantity:(NSInteger)quantity - simulatesAskToBuyInSandbox:(BOOL)simulatesAskToBuyInSandbox - paymentDiscount:(nullable FIASKPaymentDiscountMessage *)paymentDiscount { - FIASKPaymentMessage *pigeonResult = [[FIASKPaymentMessage alloc] init]; + applicationUsername:(nullable NSString *)applicationUsername + requestData:(nullable NSString *)requestData + quantity:(NSInteger )quantity + simulatesAskToBuyInSandbox:(BOOL )simulatesAskToBuyInSandbox + paymentDiscount:(nullable FIASKPaymentDiscountMessage *)paymentDiscount { + FIASKPaymentMessage* pigeonResult = [[FIASKPaymentMessage alloc] init]; pigeonResult.productIdentifier = productIdentifier; pigeonResult.applicationUsername = applicationUsername; pigeonResult.requestData = requestData; @@ -215,10 +214,10 @@ + (nullable FIASKPaymentMessage *)nullableFromList:(NSArray *)list { @end @implementation FIASKErrorMessage -+ (instancetype)makeWithCode:(NSInteger)code - domain:(NSString *)domain - userInfo:(nullable NSDictionary *)userInfo { - FIASKErrorMessage *pigeonResult = [[FIASKErrorMessage alloc] init]; ++ (instancetype)makeWithCode:(NSInteger )code + domain:(NSString *)domain + userInfo:(nullable NSDictionary *)userInfo { + FIASKErrorMessage* pigeonResult = [[FIASKErrorMessage alloc] init]; pigeonResult.code = code; pigeonResult.domain = domain; pigeonResult.userInfo = userInfo; @@ -245,11 +244,11 @@ + (nullable FIASKErrorMessage *)nullableFromList:(NSArray *)list { @implementation FIASKPaymentDiscountMessage + (instancetype)makeWithIdentifier:(NSString *)identifier - keyIdentifier:(NSString *)keyIdentifier - nonce:(NSString *)nonce - signature:(NSString *)signature - timestamp:(NSInteger)timestamp { - FIASKPaymentDiscountMessage *pigeonResult = [[FIASKPaymentDiscountMessage alloc] init]; + keyIdentifier:(NSString *)keyIdentifier + nonce:(NSString *)nonce + signature:(NSString *)signature + timestamp:(NSInteger )timestamp { + FIASKPaymentDiscountMessage* pigeonResult = [[FIASKPaymentDiscountMessage alloc] init]; pigeonResult.identifier = identifier; pigeonResult.keyIdentifier = keyIdentifier; pigeonResult.nonce = nonce; @@ -281,8 +280,9 @@ + (nullable FIASKPaymentDiscountMessage *)nullableFromList:(NSArray *)list { @end @implementation FIASKStorefrontMessage -+ (instancetype)makeWithCountryCode:(NSString *)countryCode identifier:(NSString *)identifier { - FIASKStorefrontMessage *pigeonResult = [[FIASKStorefrontMessage alloc] init]; ++ (instancetype)makeWithCountryCode:(NSString *)countryCode + identifier:(NSString *)identifier { + FIASKStorefrontMessage* pigeonResult = [[FIASKStorefrontMessage alloc] init]; pigeonResult.countryCode = countryCode; pigeonResult.identifier = identifier; return pigeonResult; @@ -306,8 +306,8 @@ + (nullable FIASKStorefrontMessage *)nullableFromList:(NSArray *)list { @implementation FIASKProductsResponseMessage + (instancetype)makeWithProducts:(nullable NSArray *)products - invalidProductIdentifiers:(nullable NSArray *)invalidProductIdentifiers { - FIASKProductsResponseMessage *pigeonResult = [[FIASKProductsResponseMessage alloc] init]; + invalidProductIdentifiers:(nullable NSArray *)invalidProductIdentifiers { + FIASKProductsResponseMessage* pigeonResult = [[FIASKProductsResponseMessage alloc] init]; pigeonResult.products = products; pigeonResult.invalidProductIdentifiers = invalidProductIdentifiers; return pigeonResult; @@ -330,17 +330,16 @@ + (nullable FIASKProductsResponseMessage *)nullableFromList:(NSArray *)list @end @implementation FIASKProductMessage -+ (instancetype) - makeWithProductIdentifier:(NSString *)productIdentifier - localizedTitle:(NSString *)localizedTitle - localizedDescription:(nullable NSString *)localizedDescription - priceLocale:(FIASKPriceLocaleMessage *)priceLocale ++ (instancetype)makeWithProductIdentifier:(NSString *)productIdentifier + localizedTitle:(NSString *)localizedTitle + localizedDescription:(nullable NSString *)localizedDescription + priceLocale:(FIASKPriceLocaleMessage *)priceLocale subscriptionGroupIdentifier:(nullable NSString *)subscriptionGroupIdentifier - price:(NSString *)price - subscriptionPeriod:(nullable FIASKProductSubscriptionPeriodMessage *)subscriptionPeriod - introductoryPrice:(nullable FIASKProductDiscountMessage *)introductoryPrice - discounts:(nullable NSArray *)discounts { - FIASKProductMessage *pigeonResult = [[FIASKProductMessage alloc] init]; + price:(NSString *)price + subscriptionPeriod:(nullable FIASKProductSubscriptionPeriodMessage *)subscriptionPeriod + introductoryPrice:(nullable FIASKProductDiscountMessage *)introductoryPrice + discounts:(nullable NSArray *)discounts { + FIASKProductMessage* pigeonResult = [[FIASKProductMessage alloc] init]; pigeonResult.productIdentifier = productIdentifier; pigeonResult.localizedTitle = localizedTitle; pigeonResult.localizedDescription = localizedDescription; @@ -385,9 +384,9 @@ + (nullable FIASKProductMessage *)nullableFromList:(NSArray *)list { @implementation FIASKPriceLocaleMessage + (instancetype)makeWithCurrencySymbol:(NSString *)currencySymbol - currencyCode:(NSString *)currencyCode - countryCode:(NSString *)countryCode { - FIASKPriceLocaleMessage *pigeonResult = [[FIASKPriceLocaleMessage alloc] init]; + currencyCode:(NSString *)currencyCode + countryCode:(NSString *)countryCode { + FIASKPriceLocaleMessage* pigeonResult = [[FIASKPriceLocaleMessage alloc] init]; pigeonResult.currencySymbol = currencySymbol; pigeonResult.currencyCode = currencyCode; pigeonResult.countryCode = countryCode; @@ -414,13 +413,13 @@ + (nullable FIASKPriceLocaleMessage *)nullableFromList:(NSArray *)list { @implementation FIASKProductDiscountMessage + (instancetype)makeWithPrice:(NSString *)price - priceLocale:(FIASKPriceLocaleMessage *)priceLocale - numberOfPeriods:(NSInteger)numberOfPeriods - paymentMode:(FIASKProductDiscountPaymentModeMessage)paymentMode - subscriptionPeriod:(FIASKProductSubscriptionPeriodMessage *)subscriptionPeriod - identifier:(nullable NSString *)identifier - type:(FIASKProductDiscountTypeMessage)type { - FIASKProductDiscountMessage *pigeonResult = [[FIASKProductDiscountMessage alloc] init]; + priceLocale:(FIASKPriceLocaleMessage *)priceLocale + numberOfPeriods:(NSInteger )numberOfPeriods + paymentMode:(FIASKProductDiscountPaymentModeMessage)paymentMode + subscriptionPeriod:(FIASKProductSubscriptionPeriodMessage *)subscriptionPeriod + identifier:(nullable NSString *)identifier + type:(FIASKProductDiscountTypeMessage)type { + FIASKProductDiscountMessage* pigeonResult = [[FIASKProductDiscountMessage alloc] init]; pigeonResult.price = price; pigeonResult.priceLocale = priceLocale; pigeonResult.numberOfPeriods = numberOfPeriods; @@ -435,13 +434,11 @@ + (FIASKProductDiscountMessage *)fromList:(NSArray *)list { pigeonResult.price = GetNullableObjectAtIndex(list, 0); pigeonResult.priceLocale = GetNullableObjectAtIndex(list, 1); pigeonResult.numberOfPeriods = [GetNullableObjectAtIndex(list, 2) integerValue]; - FIASKProductDiscountPaymentModeMessageBox *boxedFIASKProductDiscountPaymentModeMessage = - GetNullableObjectAtIndex(list, 3); + FIASKProductDiscountPaymentModeMessageBox *boxedFIASKProductDiscountPaymentModeMessage = GetNullableObjectAtIndex(list, 3); pigeonResult.paymentMode = boxedFIASKProductDiscountPaymentModeMessage.value; pigeonResult.subscriptionPeriod = GetNullableObjectAtIndex(list, 4); pigeonResult.identifier = GetNullableObjectAtIndex(list, 5); - FIASKProductDiscountTypeMessageBox *boxedFIASKProductDiscountTypeMessage = - GetNullableObjectAtIndex(list, 6); + FIASKProductDiscountTypeMessageBox *boxedFIASKProductDiscountTypeMessage = GetNullableObjectAtIndex(list, 6); pigeonResult.type = boxedFIASKProductDiscountTypeMessage.value; return pigeonResult; } @@ -462,20 +459,17 @@ + (nullable FIASKProductDiscountMessage *)nullableFromList:(NSArray *)list { @end @implementation FIASKProductSubscriptionPeriodMessage -+ (instancetype)makeWithNumberOfUnits:(NSInteger)numberOfUnits - unit:(FIASKSubscriptionPeriodUnitMessage)unit { - FIASKProductSubscriptionPeriodMessage *pigeonResult = - [[FIASKProductSubscriptionPeriodMessage alloc] init]; ++ (instancetype)makeWithNumberOfUnits:(NSInteger )numberOfUnits + unit:(FIASKSubscriptionPeriodUnitMessage)unit { + FIASKProductSubscriptionPeriodMessage* pigeonResult = [[FIASKProductSubscriptionPeriodMessage alloc] init]; pigeonResult.numberOfUnits = numberOfUnits; pigeonResult.unit = unit; return pigeonResult; } + (FIASKProductSubscriptionPeriodMessage *)fromList:(NSArray *)list { - FIASKProductSubscriptionPeriodMessage *pigeonResult = - [[FIASKProductSubscriptionPeriodMessage alloc] init]; + FIASKProductSubscriptionPeriodMessage *pigeonResult = [[FIASKProductSubscriptionPeriodMessage alloc] init]; pigeonResult.numberOfUnits = [GetNullableObjectAtIndex(list, 0) integerValue]; - FIASKSubscriptionPeriodUnitMessageBox *boxedFIASKSubscriptionPeriodUnitMessage = - GetNullableObjectAtIndex(list, 1); + FIASKSubscriptionPeriodUnitMessageBox *boxedFIASKSubscriptionPeriodUnitMessage = GetNullableObjectAtIndex(list, 1); pigeonResult.unit = boxedFIASKSubscriptionPeriodUnitMessage.value; return pigeonResult; } @@ -497,47 +491,39 @@ - (nullable id)readValueOfType:(UInt8)type { switch (type) { case 129: { NSNumber *enumAsNumber = [self readValue]; - return enumAsNumber == nil ? nil - : [[FIASKPaymentTransactionStateMessageBox alloc] - initWithValue:[enumAsNumber integerValue]]; + return enumAsNumber == nil ? nil : [[FIASKPaymentTransactionStateMessageBox alloc] initWithValue:[enumAsNumber integerValue]]; } case 130: { NSNumber *enumAsNumber = [self readValue]; - return enumAsNumber == nil ? nil - : [[FIASKProductDiscountTypeMessageBox alloc] - initWithValue:[enumAsNumber integerValue]]; + return enumAsNumber == nil ? nil : [[FIASKProductDiscountTypeMessageBox alloc] initWithValue:[enumAsNumber integerValue]]; } case 131: { NSNumber *enumAsNumber = [self readValue]; - return enumAsNumber == nil ? nil - : [[FIASKProductDiscountPaymentModeMessageBox alloc] - initWithValue:[enumAsNumber integerValue]]; + return enumAsNumber == nil ? nil : [[FIASKProductDiscountPaymentModeMessageBox alloc] initWithValue:[enumAsNumber integerValue]]; } case 132: { NSNumber *enumAsNumber = [self readValue]; - return enumAsNumber == nil ? nil - : [[FIASKSubscriptionPeriodUnitMessageBox alloc] - initWithValue:[enumAsNumber integerValue]]; + return enumAsNumber == nil ? nil : [[FIASKSubscriptionPeriodUnitMessageBox alloc] initWithValue:[enumAsNumber integerValue]]; } - case 133: + case 133: return [FIASKPaymentTransactionMessage fromList:[self readValue]]; - case 134: + case 134: return [FIASKPaymentMessage fromList:[self readValue]]; - case 135: + case 135: return [FIASKErrorMessage fromList:[self readValue]]; - case 136: + case 136: return [FIASKPaymentDiscountMessage fromList:[self readValue]]; - case 137: + case 137: return [FIASKStorefrontMessage fromList:[self readValue]]; - case 138: + case 138: return [FIASKProductsResponseMessage fromList:[self readValue]]; - case 139: + case 139: return [FIASKProductMessage fromList:[self readValue]]; - case 140: + case 140: return [FIASKPriceLocaleMessage fromList:[self readValue]]; - case 141: + case 141: return [FIASKProductDiscountMessage fromList:[self readValue]]; - case 142: + case 142: return [FIASKProductSubscriptionPeriodMessage fromList:[self readValue]]; default: return [super readValueOfType:type]; @@ -558,8 +544,7 @@ - (void)writeValue:(id)value { [self writeByte:130]; [self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])]; } else if ([value isKindOfClass:[FIASKProductDiscountPaymentModeMessageBox class]]) { - FIASKProductDiscountPaymentModeMessageBox *box = - (FIASKProductDiscountPaymentModeMessageBox *)value; + FIASKProductDiscountPaymentModeMessageBox *box = (FIASKProductDiscountPaymentModeMessageBox *)value; [self writeByte:131]; [self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])]; } else if ([value isKindOfClass:[FIASKSubscriptionPeriodUnitMessageBox class]]) { @@ -617,37 +602,26 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { static FlutterStandardMessageCodec *sSharedObject = nil; static dispatch_once_t sPred = 0; dispatch_once(&sPred, ^{ - FIAMessagesPigeonCodecReaderWriter *readerWriter = - [[FIAMessagesPigeonCodecReaderWriter alloc] init]; + FIAMessagesPigeonCodecReaderWriter *readerWriter = [[FIAMessagesPigeonCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void SetUpFIAInAppPurchaseAPI(id binaryMessenger, - NSObject *api) { +void SetUpFIAInAppPurchaseAPI(id binaryMessenger, NSObject *api) { SetUpFIAInAppPurchaseAPIWithSuffix(binaryMessenger, api, @""); } -void SetUpFIAInAppPurchaseAPIWithSuffix(id binaryMessenger, - NSObject *api, - NSString *messageChannelSuffix) { - messageChannelSuffix = messageChannelSuffix.length > 0 - ? [NSString stringWithFormat:@".%@", messageChannelSuffix] - : @""; +void SetUpFIAInAppPurchaseAPIWithSuffix(id binaryMessenger, NSObject *api, NSString *messageChannelSuffix) { + messageChannelSuffix = messageChannelSuffix.length > 0 ? [NSString stringWithFormat: @".%@", messageChannelSuffix] : @""; /// Returns if the current device is able to make payments { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat:@"%@%@", - @"dev.flutter.pigeon.in_app_purchase_storekit." - @"InAppPurchaseAPI.canMakePayments", - messageChannelSuffix] + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.canMakePayments", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:FIAGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { - NSCAssert( - [api respondsToSelector:@selector(canMakePaymentsWithError:)], - @"FIAInAppPurchaseAPI api (%@) doesn't respond to @selector(canMakePaymentsWithError:)", - api); + NSCAssert([api respondsToSelector:@selector(canMakePaymentsWithError:)], @"FIAInAppPurchaseAPI api (%@) doesn't respond to @selector(canMakePaymentsWithError:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { FlutterError *error; NSNumber *output = [api canMakePaymentsWithError:&error]; @@ -658,18 +632,13 @@ void SetUpFIAInAppPurchaseAPIWithSuffix(id binaryMesseng } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat:@"%@%@", - @"dev.flutter.pigeon.in_app_purchase_storekit." - @"InAppPurchaseAPI.transactions", - messageChannelSuffix] + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.transactions", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:FIAGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { - NSCAssert( - [api respondsToSelector:@selector(transactionsWithError:)], - @"FIAInAppPurchaseAPI api (%@) doesn't respond to @selector(transactionsWithError:)", - api); + NSCAssert([api respondsToSelector:@selector(transactionsWithError:)], @"FIAInAppPurchaseAPI api (%@) doesn't respond to @selector(transactionsWithError:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { FlutterError *error; NSArray *output = [api transactionsWithError:&error]; @@ -680,17 +649,13 @@ void SetUpFIAInAppPurchaseAPIWithSuffix(id binaryMesseng } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat:@"%@%@", - @"dev.flutter.pigeon.in_app_purchase_storekit." - @"InAppPurchaseAPI.storefront", - messageChannelSuffix] + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.storefront", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:FIAGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(storefrontWithError:)], - @"FIAInAppPurchaseAPI api (%@) doesn't respond to @selector(storefrontWithError:)", - api); + NSCAssert([api respondsToSelector:@selector(storefrontWithError:)], @"FIAInAppPurchaseAPI api (%@) doesn't respond to @selector(storefrontWithError:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { FlutterError *error; FIASKStorefrontMessage *output = [api storefrontWithError:&error]; @@ -701,18 +666,13 @@ void SetUpFIAInAppPurchaseAPIWithSuffix(id binaryMesseng } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat:@"%@%@", - @"dev.flutter.pigeon.in_app_purchase_storekit." - @"InAppPurchaseAPI.addPayment", - messageChannelSuffix] + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.addPayment", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:FIAGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { - NSCAssert( - [api respondsToSelector:@selector(addPaymentPaymentMap:error:)], - @"FIAInAppPurchaseAPI api (%@) doesn't respond to @selector(addPaymentPaymentMap:error:)", - api); + NSCAssert([api respondsToSelector:@selector(addPaymentPaymentMap:error:)], @"FIAInAppPurchaseAPI api (%@) doesn't respond to @selector(addPaymentPaymentMap:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSDictionary *arg_paymentMap = GetNullableObjectAtIndex(args, 0); @@ -725,45 +685,32 @@ void SetUpFIAInAppPurchaseAPIWithSuffix(id binaryMesseng } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat:@"%@%@", - @"dev.flutter.pigeon.in_app_purchase_storekit." - @"InAppPurchaseAPI.startProductRequest", - messageChannelSuffix] + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startProductRequest", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:FIAGetMessagesCodec()]; + 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); - [api startProductRequestProductIdentifiers:arg_productIdentifiers - completion:^(FIASKProductsResponseMessage *_Nullable output, - FlutterError *_Nullable error) { - callback(wrapResult(output, error)); - }]; + [api startProductRequestProductIdentifiers:arg_productIdentifiers completion:^(FIASKProductsResponseMessage *_Nullable output, FlutterError *_Nullable error) { + callback(wrapResult(output, error)); + }]; }]; } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat:@"%@%@", - @"dev.flutter.pigeon.in_app_purchase_storekit." - @"InAppPurchaseAPI.finishTransaction", - messageChannelSuffix] + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.finishTransaction", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:FIAGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(finishTransactionFinishMap:error:)], - @"FIAInAppPurchaseAPI api (%@) doesn't respond to " - @"@selector(finishTransactionFinishMap:error:)", - api); + NSCAssert([api respondsToSelector:@selector(finishTransactionFinishMap:error:)], @"FIAInAppPurchaseAPI api (%@) doesn't respond to @selector(finishTransactionFinishMap:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSDictionary *arg_finishMap = GetNullableObjectAtIndex(args, 0); @@ -776,18 +723,13 @@ void SetUpFIAInAppPurchaseAPIWithSuffix(id binaryMesseng } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat:@"%@%@", - @"dev.flutter.pigeon.in_app_purchase_storekit." - @"InAppPurchaseAPI.restoreTransactions", - messageChannelSuffix] + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.restoreTransactions", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:FIAGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(restoreTransactionsApplicationUserName:error:)], - @"FIAInAppPurchaseAPI api (%@) doesn't respond to " - @"@selector(restoreTransactionsApplicationUserName:error:)", - api); + NSCAssert([api respondsToSelector:@selector(restoreTransactionsApplicationUserName:error:)], @"FIAInAppPurchaseAPI api (%@) doesn't respond to @selector(restoreTransactionsApplicationUserName:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSString *arg_applicationUserName = GetNullableObjectAtIndex(args, 0); @@ -800,18 +742,13 @@ void SetUpFIAInAppPurchaseAPIWithSuffix(id binaryMesseng } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat:@"%@%@", - @"dev.flutter.pigeon.in_app_purchase_storekit." - @"InAppPurchaseAPI.presentCodeRedemptionSheet", - messageChannelSuffix] + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.presentCodeRedemptionSheet", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:FIAGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(presentCodeRedemptionSheetWithError:)], - @"FIAInAppPurchaseAPI api (%@) doesn't respond to " - @"@selector(presentCodeRedemptionSheetWithError:)", - api); + NSCAssert([api respondsToSelector:@selector(presentCodeRedemptionSheetWithError:)], @"FIAInAppPurchaseAPI api (%@) doesn't respond to @selector(presentCodeRedemptionSheetWithError:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { FlutterError *error; [api presentCodeRedemptionSheetWithError:&error]; @@ -822,18 +759,13 @@ void SetUpFIAInAppPurchaseAPIWithSuffix(id binaryMesseng } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat:@"%@%@", - @"dev.flutter.pigeon.in_app_purchase_storekit." - @"InAppPurchaseAPI.retrieveReceiptData", - messageChannelSuffix] + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.retrieveReceiptData", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:FIAGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(retrieveReceiptDataWithError:)], - @"FIAInAppPurchaseAPI api (%@) doesn't respond to " - @"@selector(retrieveReceiptDataWithError:)", - api); + NSCAssert([api respondsToSelector:@selector(retrieveReceiptDataWithError:)], @"FIAInAppPurchaseAPI api (%@) doesn't respond to @selector(retrieveReceiptDataWithError:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { FlutterError *error; NSString *output = [api retrieveReceiptDataWithError:&error]; @@ -844,43 +776,32 @@ void SetUpFIAInAppPurchaseAPIWithSuffix(id binaryMesseng } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat:@"%@%@", - @"dev.flutter.pigeon.in_app_purchase_storekit." - @"InAppPurchaseAPI.refreshReceipt", - messageChannelSuffix] + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.refreshReceipt", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:FIAGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(refreshReceiptReceiptProperties:completion:)], - @"FIAInAppPurchaseAPI api (%@) doesn't respond to " - @"@selector(refreshReceiptReceiptProperties:completion:)", - api); + NSCAssert([api respondsToSelector:@selector(refreshReceiptReceiptProperties:completion:)], @"FIAInAppPurchaseAPI api (%@) doesn't respond to @selector(refreshReceiptReceiptProperties:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; NSDictionary *arg_receiptProperties = GetNullableObjectAtIndex(args, 0); - [api refreshReceiptReceiptProperties:arg_receiptProperties - completion:^(FlutterError *_Nullable error) { - callback(wrapResult(nil, error)); - }]; + [api refreshReceiptReceiptProperties:arg_receiptProperties completion:^(FlutterError *_Nullable error) { + callback(wrapResult(nil, error)); + }]; }]; } else { [channel setMessageHandler:nil]; } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat:@"%@%@", - @"dev.flutter.pigeon.in_app_purchase_storekit." - @"InAppPurchaseAPI.startObservingPaymentQueue", - messageChannelSuffix] + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startObservingPaymentQueue", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:FIAGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(startObservingPaymentQueueWithError:)], - @"FIAInAppPurchaseAPI api (%@) doesn't respond to " - @"@selector(startObservingPaymentQueueWithError:)", - api); + NSCAssert([api respondsToSelector:@selector(startObservingPaymentQueueWithError:)], @"FIAInAppPurchaseAPI api (%@) doesn't respond to @selector(startObservingPaymentQueueWithError:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { FlutterError *error; [api startObservingPaymentQueueWithError:&error]; @@ -891,18 +812,13 @@ void SetUpFIAInAppPurchaseAPIWithSuffix(id binaryMesseng } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat:@"%@%@", - @"dev.flutter.pigeon.in_app_purchase_storekit." - @"InAppPurchaseAPI.stopObservingPaymentQueue", - messageChannelSuffix] + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.stopObservingPaymentQueue", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:FIAGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(stopObservingPaymentQueueWithError:)], - @"FIAInAppPurchaseAPI api (%@) doesn't respond to " - @"@selector(stopObservingPaymentQueueWithError:)", - api); + NSCAssert([api respondsToSelector:@selector(stopObservingPaymentQueueWithError:)], @"FIAInAppPurchaseAPI api (%@) doesn't respond to @selector(stopObservingPaymentQueueWithError:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { FlutterError *error; [api stopObservingPaymentQueueWithError:&error]; @@ -913,18 +829,13 @@ void SetUpFIAInAppPurchaseAPIWithSuffix(id binaryMesseng } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat:@"%@%@", - @"dev.flutter.pigeon.in_app_purchase_storekit." - @"InAppPurchaseAPI.registerPaymentQueueDelegate", - messageChannelSuffix] + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.registerPaymentQueueDelegate", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:FIAGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(registerPaymentQueueDelegateWithError:)], - @"FIAInAppPurchaseAPI api (%@) doesn't respond to " - @"@selector(registerPaymentQueueDelegateWithError:)", - api); + NSCAssert([api respondsToSelector:@selector(registerPaymentQueueDelegateWithError:)], @"FIAInAppPurchaseAPI api (%@) doesn't respond to @selector(registerPaymentQueueDelegateWithError:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { FlutterError *error; [api registerPaymentQueueDelegateWithError:&error]; @@ -935,18 +846,13 @@ void SetUpFIAInAppPurchaseAPIWithSuffix(id binaryMesseng } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat:@"%@%@", - @"dev.flutter.pigeon.in_app_purchase_storekit." - @"InAppPurchaseAPI.removePaymentQueueDelegate", - messageChannelSuffix] + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.removePaymentQueueDelegate", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:FIAGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(removePaymentQueueDelegateWithError:)], - @"FIAInAppPurchaseAPI api (%@) doesn't respond to " - @"@selector(removePaymentQueueDelegateWithError:)", - api); + NSCAssert([api respondsToSelector:@selector(removePaymentQueueDelegateWithError:)], @"FIAInAppPurchaseAPI api (%@) doesn't respond to @selector(removePaymentQueueDelegateWithError:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { FlutterError *error; [api removePaymentQueueDelegateWithError:&error]; @@ -957,18 +863,13 @@ void SetUpFIAInAppPurchaseAPIWithSuffix(id binaryMesseng } } { - FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat:@"%@%@", - @"dev.flutter.pigeon.in_app_purchase_storekit." - @"InAppPurchaseAPI.showPriceConsentIfNeeded", - messageChannelSuffix] + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.showPriceConsentIfNeeded", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:FIAGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(showPriceConsentIfNeededWithError:)], - @"FIAInAppPurchaseAPI api (%@) doesn't respond to " - @"@selector(showPriceConsentIfNeededWithError:)", - api); + NSCAssert([api respondsToSelector:@selector(showPriceConsentIfNeededWithError:)], @"FIAInAppPurchaseAPI api (%@) doesn't respond to @selector(showPriceConsentIfNeededWithError:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { FlutterError *error; [api showPriceConsentIfNeededWithError:&error]; 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 e74b46ddfc2f..57352b548ef7 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 @@ -249,8 +249,9 @@ class InAppPurchaseStoreKitPlatform extends InAppPurchasePlatform { Future getCountryCode() => countryCode(); /// Turns on StoreKit2. You cannot disable this after it is enabled. - void enableStoreKit2() { - _useStoreKit2 = true; + Future enableStoreKit2() async { + _useStoreKit2 = await AppStore.supportsStoreKit2(); + return _useStoreKit2; } } diff --git a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/messages.g.dart b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/messages.g.dart index 8679df86f749..f0f8cdace5f4 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/messages.g.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/messages.g.dart @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v22.4.2), do not edit directly. +// Autogenerated from Pigeon (v22.6.0), 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, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers 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 1339471a088b..177dc5aa36a6 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 @@ -719,6 +719,35 @@ class InAppPurchase2API { return; } } + + Future supportsStoreKit2() async { + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.supportsStoreKit2$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send(null) 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?)!; + } + } } abstract class InAppPurchase2CallbackAPI { 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 a57ad5611266..523a7a6ba5f7 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 @@ -15,4 +15,9 @@ final class AppStore { Future canMakePayments() { return _hostApi.canMakePayments(); } + + /// Checks the device version to determine if it supports StoreKit 2. + static Future supportsStoreKit2() { + return _hostApi.supportsStoreKit2(); + } } diff --git a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_wrappers/sk_storefront_wrapper.dart b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_wrappers/sk_storefront_wrapper.dart index 2ba25e08616a..a31c3793ebcd 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_wrappers/sk_storefront_wrapper.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_wrappers/sk_storefront_wrapper.dart @@ -9,6 +9,8 @@ import '../messages.g.dart'; part 'sk_storefront_wrapper.g.dart'; +InAppPurchaseAPI _hostApi = InAppPurchaseAPI(); + /// Contains the location and unique identifier of an Apple App Store storefront. /// /// Dart wrapper around StoreKit's 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 77239af47236..c4e2b37e14a1 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 @@ -196,6 +196,8 @@ abstract class InAppPurchase2API { @async void restorePurchases(); + + bool supportsStoreKit2(); } @FlutterApi() diff --git a/packages/in_app_purchase/in_app_purchase_storekit/pubspec.yaml b/packages/in_app_purchase/in_app_purchase_storekit/pubspec.yaml index aa3c1d7b3e64..dd15dd6062ed 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/pubspec.yaml +++ b/packages/in_app_purchase/in_app_purchase_storekit/pubspec.yaml @@ -2,7 +2,7 @@ name: in_app_purchase_storekit description: An implementation for the iOS and macOS platforms of the Flutter `in_app_purchase` plugin. This uses the StoreKit Framework. repository: https://github.com/flutter/packages/tree/main/packages/in_app_purchase/in_app_purchase_storekit issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22 -version: 0.3.20 +version: 0.3.20+1 environment: sdk: ^3.3.0 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 55c490bb62b4..9c6b283409e5 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 @@ -389,6 +389,11 @@ class FakeStoreKit2Platform implements TestInAppPurchase2Api { InAppPurchaseStoreKitPlatform.sk2TransactionObserver .onTransactionsUpdated(transactionList); } + + @override + bool supportsStoreKit2() { + return true; + } } SK2TransactionMessage createPendingTransaction(String id, {int quantity = 1}) { diff --git a/packages/in_app_purchase/in_app_purchase_storekit/test/in_app_purchase_storekit_2_platform_test.dart b/packages/in_app_purchase/in_app_purchase_storekit/test/in_app_purchase_storekit_2_platform_test.dart index 6fb2ba030704..3e58d4c2fe7f 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/test/in_app_purchase_storekit_2_platform_test.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/test/in_app_purchase_storekit_2_platform_test.dart @@ -48,6 +48,10 @@ void main() { }); }); + test('storekit 2 is unsupported', () async { + expect(fakeStoreKit2Platform.supportsStoreKit2(), true); + }); + group('query product list', () { test('should get product list and correct invalid identifiers', () async { final InAppPurchaseStoreKitPlatform connection = diff --git a/packages/in_app_purchase/in_app_purchase_storekit/test/sk2_test_api.g.dart b/packages/in_app_purchase/in_app_purchase_storekit/test/sk2_test_api.g.dart index 5c595d45c09e..9ad21ed4a790 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/test/sk2_test_api.g.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/test/sk2_test_api.g.dart @@ -134,6 +134,8 @@ abstract class TestInAppPurchase2Api { Future restorePurchases(); + bool supportsStoreKit2(); + static void setUp( TestInAppPurchase2Api? api, { BinaryMessenger? binaryMessenger, @@ -372,5 +374,31 @@ abstract class TestInAppPurchase2Api { }); } } + { + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.supportsStoreKit2$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, + (Object? message) async { + try { + final bool output = api.supportsStoreKit2(); + return [output]; + } on PlatformException catch (e) { + return wrapResponse(error: e); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); + } + }); + } + } } } diff --git a/packages/in_app_purchase/in_app_purchase_storekit/test/store_kit_wrappers/sk_methodchannel_apis_test.dart b/packages/in_app_purchase/in_app_purchase_storekit/test/store_kit_wrappers/sk_methodchannel_apis_test.dart index b774552f84ba..6e046d6dfc9c 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/test/store_kit_wrappers/sk_methodchannel_apis_test.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/test/store_kit_wrappers/sk_methodchannel_apis_test.dart @@ -304,6 +304,11 @@ class FakeStoreKitPlatform implements TestInAppPurchaseApi { void showPriceConsentIfNeeded() { showPriceConsent = true; } + + @override + bool supportsStoreKit2() { + return false; + } } class TestPaymentQueueDelegate extends SKPaymentQueueDelegateWrapper {} diff --git a/packages/in_app_purchase/in_app_purchase_storekit/test/test_api.g.dart b/packages/in_app_purchase/in_app_purchase_storekit/test/test_api.g.dart index 2092930d208d..28ecc1aa19ce 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/test/test_api.g.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/test/test_api.g.dart @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v22.4.2), do not edit directly. +// Autogenerated from Pigeon (v22.6.0), 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, unnecessary_import, no_leading_underscores_for_local_identifiers // ignore_for_file: avoid_relative_lib_imports