From 9af7e22b355d22c216819627a167416fb2d5cf7e Mon Sep 17 00:00:00 2001 From: louisehsu Date: Fri, 15 Nov 2024 15:47:11 -0800 Subject: [PATCH 01/12] . --- .../darwin/Classes/InAppPurchasePlugin.swift | 7 + .../darwin/Classes/messages.g.h | 197 ++++---- .../darwin/Classes/messages.g.m | 424 +++++++----------- .../example/lib/main.dart | 1 + .../in_app_purchase_storekit_platform.dart | 5 +- .../lib/src/messages.g.dart | 231 +++++----- .../store_kit_wrappers/sk_request_maker.dart | 4 + .../pigeons/messages.dart | 2 + .../test/fakes/fake_storekit_platform.dart | 6 + .../sk_methodchannel_apis_test.dart | 6 + .../test/test_api.g.dart | 421 +++++++---------- 11 files changed, 556 insertions(+), 748 deletions(-) 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 23b8972c96c..b566bc2fa27 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 @@ -12,6 +12,13 @@ import StoreKit #endif public class InAppPurchasePlugin: NSObject, FlutterPlugin, FIAInAppPurchaseAPI { + public func supportsStoreKit2WithError(_ error: AutoreleasingUnsafeMutablePointer) -> NSNumber? { + if #available(iOS 15.0, macOS 15.0, *) { + return true + } + return false + } + private let receiptManager: FIAPReceiptManager private var productsCache: NSMutableDictionary = [:] private var paymentQueueDelegateCallbackChannel: FlutterMethodChannel? 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 a6059f269d7..e61fbf612f7 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,35 +255,27 @@ 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; - (void)removePaymentQueueDelegateWithError:(FlutterError *_Nullable *_Nonnull)error; - (void)showPriceConsentIfNeededWithError:(FlutterError *_Nullable *_Nonnull)error; +/// @return `nil` only when `error != nil`. +- (nullable NSNumber *)supportsStoreKit2WithError:(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 62988eb04fe..c3ad1f414d7 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]; @@ -978,4 +879,21 @@ void SetUpFIAInAppPurchaseAPIWithSuffix(id binaryMesseng [channel setMessageHandler:nil]; } } + { + FlutterBasicMessageChannel *channel = + [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.supportsStoreKit2", messageChannelSuffix] + binaryMessenger:binaryMessenger + codec:FIAGetMessagesCodec()]; + if (api) { + NSCAssert([api respondsToSelector:@selector(supportsStoreKit2WithError:)], @"FIAInAppPurchaseAPI api (%@) doesn't respond to @selector(supportsStoreKit2WithError:)", api); + [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { + FlutterError *error; + NSNumber *output = [api supportsStoreKit2WithError:&error]; + callback(wrapResult(output, error)); + }]; + } else { + [channel setMessageHandler:nil]; + } + } } 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 cab8ddf0c2d..06950a977e5 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 @@ -17,6 +17,7 @@ void main() { // When using the Android plugin directly it is mandatory to register // the plugin as default instance as part of initializing the app. InAppPurchaseStoreKitPlatform.registerPlatform(); + InAppPurchaseStoreKitPlatform.enableStoreKit2(); runApp(_MyApp()); } 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 f930e57a8e7..f0963d22585 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 @@ -246,8 +246,9 @@ class InAppPurchaseStoreKitPlatform extends InAppPurchasePlatform { Future getCountryCode() => countryCode(); /// Turns on StoreKit2. You cannot disable this after it is enabled. - void enableStoreKit2() { - _useStoreKit2 = true; + static Future enableStoreKit2() async { + _useStoreKit2 = await SKRequestMaker.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 8679df86f74..48b8ae8997e 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 @@ -18,8 +18,7 @@ PlatformException _createConnectionError(String channelName) { ); } -List wrapResponse( - {Object? result, PlatformException? error, bool empty = false}) { +List wrapResponse({Object? result, PlatformException? error, bool empty = false}) { if (empty) { return []; } @@ -36,32 +35,27 @@ enum SKPaymentTransactionStateMessage { /// transaction to update to another state. Never complete a transaction that /// is still in a purchasing state. purchasing, - /// The user's payment has been succesfully processed. /// /// You should provide the user the content that they purchased. purchased, - /// The transaction failed. /// /// Check the [PaymentTransactionWrapper.error] property from /// [PaymentTransactionWrapper] for details. failed, - /// This transaction is restoring content previously purchased by the user. /// /// The previous transaction information can be obtained in /// [PaymentTransactionWrapper.originalTransaction] from /// [PaymentTransactionWrapper]. restored, - /// The transaction is in the queue but pending external action. Wait for /// another callback to get the final state. /// /// You should update your UI to indicate that you are waiting for the /// transaction to update to another state. deferred, - /// Indicates the transaction is in an unspecified state. unspecified, } @@ -69,7 +63,6 @@ enum SKPaymentTransactionStateMessage { enum SKProductDiscountTypeMessage { /// A constant indicating the discount type is an introductory offer. introductory, - /// A constant indicating the discount type is a promotional offer. subscription, } @@ -77,13 +70,10 @@ enum SKProductDiscountTypeMessage { enum SKProductDiscountPaymentModeMessage { /// Allows user to pay the discounted price at each payment period. payAsYouGo, - /// Allows user to pay the discounted price upfront and receive the product for the rest of time that was paid for. payUpFront, - /// User pays nothing during the discounted period. freeTrial, - /// Unspecified mode. unspecified, } @@ -367,8 +357,7 @@ class SKProductMessage { price: result[5]! as String, subscriptionPeriod: result[6] as SKProductSubscriptionPeriodMessage?, introductoryPrice: result[7] as SKProductDiscountMessage?, - discounts: - (result[8] as List?)?.cast(), + discounts: (result[8] as List?)?.cast(), ); } } @@ -484,6 +473,7 @@ class SKProductSubscriptionPeriodMessage { } } + class _PigeonCodec extends StandardMessageCodec { const _PigeonCodec(); @override @@ -491,46 +481,46 @@ class _PigeonCodec extends StandardMessageCodec { if (value is int) { buffer.putUint8(4); buffer.putInt64(value); - } else if (value is SKPaymentTransactionStateMessage) { + } else if (value is SKPaymentTransactionStateMessage) { buffer.putUint8(129); writeValue(buffer, value.index); - } else if (value is SKProductDiscountTypeMessage) { + } else if (value is SKProductDiscountTypeMessage) { buffer.putUint8(130); writeValue(buffer, value.index); - } else if (value is SKProductDiscountPaymentModeMessage) { + } else if (value is SKProductDiscountPaymentModeMessage) { buffer.putUint8(131); writeValue(buffer, value.index); - } else if (value is SKSubscriptionPeriodUnitMessage) { + } else if (value is SKSubscriptionPeriodUnitMessage) { buffer.putUint8(132); writeValue(buffer, value.index); - } else if (value is SKPaymentTransactionMessage) { + } else if (value is SKPaymentTransactionMessage) { buffer.putUint8(133); writeValue(buffer, value.encode()); - } else if (value is SKPaymentMessage) { + } else if (value is SKPaymentMessage) { buffer.putUint8(134); writeValue(buffer, value.encode()); - } else if (value is SKErrorMessage) { + } else if (value is SKErrorMessage) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else if (value is SKPaymentDiscountMessage) { + } else if (value is SKPaymentDiscountMessage) { buffer.putUint8(136); writeValue(buffer, value.encode()); - } else if (value is SKStorefrontMessage) { + } else if (value is SKStorefrontMessage) { buffer.putUint8(137); writeValue(buffer, value.encode()); - } else if (value is SKProductsResponseMessage) { + } else if (value is SKProductsResponseMessage) { buffer.putUint8(138); writeValue(buffer, value.encode()); - } else if (value is SKProductMessage) { + } else if (value is SKProductMessage) { buffer.putUint8(139); writeValue(buffer, value.encode()); - } else if (value is SKPriceLocaleMessage) { + } else if (value is SKPriceLocaleMessage) { buffer.putUint8(140); writeValue(buffer, value.encode()); - } else if (value is SKProductDiscountMessage) { + } else if (value is SKProductDiscountMessage) { buffer.putUint8(141); writeValue(buffer, value.encode()); - } else if (value is SKProductSubscriptionPeriodMessage) { + } else if (value is SKProductSubscriptionPeriodMessage) { buffer.putUint8(142); writeValue(buffer, value.encode()); } else { @@ -541,45 +531,37 @@ class _PigeonCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 129: + case 129: final int? value = readValue(buffer) as int?; - return value == null - ? null - : SKPaymentTransactionStateMessage.values[value]; - case 130: + return value == null ? null : SKPaymentTransactionStateMessage.values[value]; + case 130: final int? value = readValue(buffer) as int?; - return value == null - ? null - : SKProductDiscountTypeMessage.values[value]; - case 131: + return value == null ? null : SKProductDiscountTypeMessage.values[value]; + case 131: final int? value = readValue(buffer) as int?; - return value == null - ? null - : SKProductDiscountPaymentModeMessage.values[value]; - case 132: + return value == null ? null : SKProductDiscountPaymentModeMessage.values[value]; + case 132: final int? value = readValue(buffer) as int?; - return value == null - ? null - : SKSubscriptionPeriodUnitMessage.values[value]; - case 133: + return value == null ? null : SKSubscriptionPeriodUnitMessage.values[value]; + case 133: return SKPaymentTransactionMessage.decode(readValue(buffer)!); - case 134: + case 134: return SKPaymentMessage.decode(readValue(buffer)!); - case 135: + case 135: return SKErrorMessage.decode(readValue(buffer)!); - case 136: + case 136: return SKPaymentDiscountMessage.decode(readValue(buffer)!); - case 137: + case 137: return SKStorefrontMessage.decode(readValue(buffer)!); - case 138: + case 138: return SKProductsResponseMessage.decode(readValue(buffer)!); - case 139: + case 139: return SKProductMessage.decode(readValue(buffer)!); - case 140: + case 140: return SKPriceLocaleMessage.decode(readValue(buffer)!); - case 141: + case 141: return SKProductDiscountMessage.decode(readValue(buffer)!); - case 142: + case 142: return SKProductSubscriptionPeriodMessage.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -591,11 +573,9 @@ class InAppPurchaseAPI { /// Constructor for [InAppPurchaseAPI]. 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. - InAppPurchaseAPI( - {BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) + InAppPurchaseAPI({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) : pigeonVar_binaryMessenger = binaryMessenger, - pigeonVar_messageChannelSuffix = - messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; final BinaryMessenger? pigeonVar_binaryMessenger; static const MessageCodec pigeonChannelCodec = _PigeonCodec(); @@ -604,10 +584,8 @@ class InAppPurchaseAPI { /// Returns if the current device is able to make payments Future canMakePayments() async { - final String pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.canMakePayments$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = - BasicMessageChannel( + final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.canMakePayments$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, @@ -633,10 +611,8 @@ class InAppPurchaseAPI { } Future> transactions() async { - final String pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.transactions$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = - BasicMessageChannel( + final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.transactions$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, @@ -657,16 +633,13 @@ class InAppPurchaseAPI { message: 'Host platform returned null value for non-null return value.', ); } else { - return (pigeonVar_replyList[0] as List?)! - .cast(); + return (pigeonVar_replyList[0] as List?)!.cast(); } } Future storefront() async { - final String pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.storefront$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = - BasicMessageChannel( + final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.storefront$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, @@ -692,10 +665,8 @@ class InAppPurchaseAPI { } Future addPayment(Map paymentMap) async { - final String pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.addPayment$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = - BasicMessageChannel( + final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.addPayment$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, @@ -715,18 +686,15 @@ class InAppPurchaseAPI { } } - Future startProductRequest( - List productIdentifiers) async { - final String pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startProductRequest$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = - BasicMessageChannel( + Future startProductRequest(List productIdentifiers) async { + final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startProductRequest$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([productIdentifiers]) as List?; + final List? pigeonVar_replyList = + await pigeonVar_channel.send([productIdentifiers]) as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -746,10 +714,8 @@ class InAppPurchaseAPI { } Future finishTransaction(Map finishMap) async { - final String pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.finishTransaction$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = - BasicMessageChannel( + final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.finishTransaction$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, @@ -770,16 +736,14 @@ class InAppPurchaseAPI { } Future restoreTransactions(String? applicationUserName) async { - final String pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.restoreTransactions$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = - BasicMessageChannel( + final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.restoreTransactions$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([applicationUserName]) as List?; + final List? pigeonVar_replyList = + await pigeonVar_channel.send([applicationUserName]) as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -794,10 +758,8 @@ class InAppPurchaseAPI { } Future presentCodeRedemptionSheet() async { - final String pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.presentCodeRedemptionSheet$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = - BasicMessageChannel( + final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.presentCodeRedemptionSheet$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, @@ -818,10 +780,8 @@ class InAppPurchaseAPI { } Future retrieveReceiptData() async { - final String pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.retrieveReceiptData$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = - BasicMessageChannel( + final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.retrieveReceiptData$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, @@ -842,16 +802,14 @@ class InAppPurchaseAPI { } Future refreshReceipt({Map? receiptProperties}) async { - final String pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.refreshReceipt$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = - BasicMessageChannel( + final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.refreshReceipt$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([receiptProperties]) as List?; + final List? pigeonVar_replyList = + await pigeonVar_channel.send([receiptProperties]) as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -866,10 +824,8 @@ class InAppPurchaseAPI { } Future startObservingPaymentQueue() async { - final String pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startObservingPaymentQueue$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = - BasicMessageChannel( + final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startObservingPaymentQueue$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, @@ -890,10 +846,8 @@ class InAppPurchaseAPI { } Future stopObservingPaymentQueue() async { - final String pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.stopObservingPaymentQueue$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = - BasicMessageChannel( + final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.stopObservingPaymentQueue$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, @@ -914,10 +868,8 @@ class InAppPurchaseAPI { } Future registerPaymentQueueDelegate() async { - final String pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.registerPaymentQueueDelegate$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = - BasicMessageChannel( + final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.registerPaymentQueueDelegate$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, @@ -938,10 +890,8 @@ class InAppPurchaseAPI { } Future removePaymentQueueDelegate() async { - final String pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.removePaymentQueueDelegate$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = - BasicMessageChannel( + final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.removePaymentQueueDelegate$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, @@ -962,10 +912,8 @@ class InAppPurchaseAPI { } Future showPriceConsentIfNeeded() async { - final String pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.showPriceConsentIfNeeded$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = - BasicMessageChannel( + final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.showPriceConsentIfNeeded$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, @@ -984,4 +932,31 @@ class InAppPurchaseAPI { return; } } + + Future supportsStoreKit2() async { + final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.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?)!; + } + } } diff --git a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_wrappers/sk_request_maker.dart b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_wrappers/sk_request_maker.dart index 9075db9157a..173d6ab6cf6 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_wrappers/sk_request_maker.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_wrappers/sk_request_maker.dart @@ -55,4 +55,8 @@ class SKRequestMaker { {Map? receiptProperties}) { return _hostApi.refreshReceipt(receiptProperties: receiptProperties); } + + static Future supportsStoreKit2() async { + return _hostApi.supportsStoreKit2(); + } } diff --git a/packages/in_app_purchase/in_app_purchase_storekit/pigeons/messages.dart b/packages/in_app_purchase/in_app_purchase_storekit/pigeons/messages.dart index cd7b6b70a57..774ab69e220 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/pigeons/messages.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/pigeons/messages.dart @@ -264,4 +264,6 @@ abstract class InAppPurchaseAPI { void removePaymentQueueDelegate(); void showPriceConsentIfNeeded(); + + bool supportsStoreKit2(); } 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 29932a9f818..b0a6ed35ce0 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 @@ -280,6 +280,12 @@ class FakeStoreKitPlatform implements TestInAppPurchaseApi { void stopObservingPaymentQueue() { queueIsActive = false; } + + @override + bool supportsStoreKit2() { + // TODO: implement supportsStoreKit2 + throw UnimplementedError(); + } } class FakeStoreKit2Platform implements TestInAppPurchase2Api { 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 b774552f84b..88d2972c296 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,12 @@ class FakeStoreKitPlatform implements TestInAppPurchaseApi { void showPriceConsentIfNeeded() { showPriceConsent = true; } + + @override + bool supportsStoreKit2() { + // TODO: implement supportsStoreKit2 + throw UnimplementedError(); + } } 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 2092930d208..963dcdb3dce 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 @@ -13,6 +13,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:in_app_purchase_storekit/src/messages.g.dart'; + class _PigeonCodec extends StandardMessageCodec { const _PigeonCodec(); @override @@ -20,46 +21,46 @@ class _PigeonCodec extends StandardMessageCodec { if (value is int) { buffer.putUint8(4); buffer.putInt64(value); - } else if (value is SKPaymentTransactionStateMessage) { + } else if (value is SKPaymentTransactionStateMessage) { buffer.putUint8(129); writeValue(buffer, value.index); - } else if (value is SKProductDiscountTypeMessage) { + } else if (value is SKProductDiscountTypeMessage) { buffer.putUint8(130); writeValue(buffer, value.index); - } else if (value is SKProductDiscountPaymentModeMessage) { + } else if (value is SKProductDiscountPaymentModeMessage) { buffer.putUint8(131); writeValue(buffer, value.index); - } else if (value is SKSubscriptionPeriodUnitMessage) { + } else if (value is SKSubscriptionPeriodUnitMessage) { buffer.putUint8(132); writeValue(buffer, value.index); - } else if (value is SKPaymentTransactionMessage) { + } else if (value is SKPaymentTransactionMessage) { buffer.putUint8(133); writeValue(buffer, value.encode()); - } else if (value is SKPaymentMessage) { + } else if (value is SKPaymentMessage) { buffer.putUint8(134); writeValue(buffer, value.encode()); - } else if (value is SKErrorMessage) { + } else if (value is SKErrorMessage) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else if (value is SKPaymentDiscountMessage) { + } else if (value is SKPaymentDiscountMessage) { buffer.putUint8(136); writeValue(buffer, value.encode()); - } else if (value is SKStorefrontMessage) { + } else if (value is SKStorefrontMessage) { buffer.putUint8(137); writeValue(buffer, value.encode()); - } else if (value is SKProductsResponseMessage) { + } else if (value is SKProductsResponseMessage) { buffer.putUint8(138); writeValue(buffer, value.encode()); - } else if (value is SKProductMessage) { + } else if (value is SKProductMessage) { buffer.putUint8(139); writeValue(buffer, value.encode()); - } else if (value is SKPriceLocaleMessage) { + } else if (value is SKPriceLocaleMessage) { buffer.putUint8(140); writeValue(buffer, value.encode()); - } else if (value is SKProductDiscountMessage) { + } else if (value is SKProductDiscountMessage) { buffer.putUint8(141); writeValue(buffer, value.encode()); - } else if (value is SKProductSubscriptionPeriodMessage) { + } else if (value is SKProductSubscriptionPeriodMessage) { buffer.putUint8(142); writeValue(buffer, value.encode()); } else { @@ -70,45 +71,37 @@ class _PigeonCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 129: + case 129: final int? value = readValue(buffer) as int?; - return value == null - ? null - : SKPaymentTransactionStateMessage.values[value]; - case 130: + return value == null ? null : SKPaymentTransactionStateMessage.values[value]; + case 130: final int? value = readValue(buffer) as int?; - return value == null - ? null - : SKProductDiscountTypeMessage.values[value]; - case 131: + return value == null ? null : SKProductDiscountTypeMessage.values[value]; + case 131: final int? value = readValue(buffer) as int?; - return value == null - ? null - : SKProductDiscountPaymentModeMessage.values[value]; - case 132: + return value == null ? null : SKProductDiscountPaymentModeMessage.values[value]; + case 132: final int? value = readValue(buffer) as int?; - return value == null - ? null - : SKSubscriptionPeriodUnitMessage.values[value]; - case 133: + return value == null ? null : SKSubscriptionPeriodUnitMessage.values[value]; + case 133: return SKPaymentTransactionMessage.decode(readValue(buffer)!); - case 134: + case 134: return SKPaymentMessage.decode(readValue(buffer)!); - case 135: + case 135: return SKErrorMessage.decode(readValue(buffer)!); - case 136: + case 136: return SKPaymentDiscountMessage.decode(readValue(buffer)!); - case 137: + case 137: return SKStorefrontMessage.decode(readValue(buffer)!); - case 138: + case 138: return SKProductsResponseMessage.decode(readValue(buffer)!); - case 139: + case 139: return SKProductMessage.decode(readValue(buffer)!); - case 140: + case 140: return SKPriceLocaleMessage.decode(readValue(buffer)!); - case 141: + case 141: return SKProductDiscountMessage.decode(readValue(buffer)!); - case 142: + case 142: return SKProductSubscriptionPeriodMessage.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -117,8 +110,7 @@ class _PigeonCodec extends StandardMessageCodec { } abstract class TestInAppPurchaseApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => - TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; static const MessageCodec pigeonChannelCodec = _PigeonCodec(); /// Returns if the current device is able to make payments @@ -130,8 +122,7 @@ abstract class TestInAppPurchaseApi { void addPayment(Map paymentMap); - Future startProductRequest( - List productIdentifiers); + Future startProductRequest(List productIdentifiers); void finishTransaction(Map finishMap); @@ -153,110 +144,79 @@ abstract class TestInAppPurchaseApi { void showPriceConsentIfNeeded(); - static void setUp( - TestInAppPurchaseApi? api, { - BinaryMessenger? binaryMessenger, - String messageChannelSuffix = '', - }) { - messageChannelSuffix = - messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + bool supportsStoreKit2(); + + static void setUp(TestInAppPurchaseApi? api, {BinaryMessenger? binaryMessenger, String messageChannelSuffix = '',}) { + messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.canMakePayments$messageChannelSuffix', - pigeonChannelCodec, + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.canMakePayments$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { try { final bool output = api.canMakePayments(); return [output]; } 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())); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.transactions$messageChannelSuffix', - pigeonChannelCodec, + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.transactions$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { try { final List output = api.transactions(); return [output]; } 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())); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.storefront$messageChannelSuffix', - pigeonChannelCodec, + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.storefront$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { try { final SKStorefrontMessage output = api.storefront(); return [output]; } 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())); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.addPayment$messageChannelSuffix', - pigeonChannelCodec, + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.addPayment$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.addPayment was null.'); + 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.addPayment was null.'); final List args = (message as List?)!; - final Map? arg_paymentMap = - (args[0] as Map?)?.cast(); + final Map? arg_paymentMap = (args[0] as Map?)?.cast(); assert(arg_paymentMap != null, 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.addPayment was null, expected non-null Map.'); try { @@ -264,66 +224,49 @@ abstract class TestInAppPurchaseApi { 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())); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startProductRequest$messageChannelSuffix', - pigeonChannelCodec, + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startProductRequest$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startProductRequest was null.'); + 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startProductRequest was null.'); final List args = (message as List?)!; - final List? arg_productIdentifiers = - (args[0] as List?)?.cast(); + final List? arg_productIdentifiers = (args[0] as List?)?.cast(); assert(arg_productIdentifiers != null, 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startProductRequest was null, expected non-null List.'); try { - final SKProductsResponseMessage output = - await api.startProductRequest(arg_productIdentifiers!); + final SKProductsResponseMessage output = await api.startProductRequest(arg_productIdentifiers!); return [output]; } 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())); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.finishTransaction$messageChannelSuffix', - pigeonChannelCodec, + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.finishTransaction$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.finishTransaction was null.'); + 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.finishTransaction was null.'); final List args = (message as List?)!; - final Map? arg_finishMap = - (args[0] as Map?)?.cast(); + final Map? arg_finishMap = (args[0] as Map?)?.cast(); assert(arg_finishMap != null, 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.finishTransaction was null, expected non-null Map.'); try { @@ -331,29 +274,22 @@ abstract class TestInAppPurchaseApi { 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())); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.restoreTransactions$messageChannelSuffix', - pigeonChannelCodec, + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.restoreTransactions$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.restoreTransactions was null.'); + 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.restoreTransactions was null.'); final List args = (message as List?)!; final String? arg_applicationUserName = (args[0] as String?); try { @@ -361,222 +297,183 @@ abstract class TestInAppPurchaseApi { 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())); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.presentCodeRedemptionSheet$messageChannelSuffix', - pigeonChannelCodec, + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.presentCodeRedemptionSheet$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { try { api.presentCodeRedemptionSheet(); 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())); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.retrieveReceiptData$messageChannelSuffix', - pigeonChannelCodec, + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.retrieveReceiptData$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { try { final String? output = api.retrieveReceiptData(); return [output]; } 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())); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.refreshReceipt$messageChannelSuffix', - pigeonChannelCodec, + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.refreshReceipt$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.refreshReceipt was null.'); + 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.refreshReceipt was null.'); final List args = (message as List?)!; - final Map? arg_receiptProperties = - (args[0] as Map?)?.cast(); + final Map? arg_receiptProperties = (args[0] as Map?)?.cast(); try { await api.refreshReceipt(receiptProperties: arg_receiptProperties); 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())); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startObservingPaymentQueue$messageChannelSuffix', - pigeonChannelCodec, + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startObservingPaymentQueue$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { try { api.startObservingPaymentQueue(); 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())); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.stopObservingPaymentQueue$messageChannelSuffix', - pigeonChannelCodec, + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.stopObservingPaymentQueue$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { try { api.stopObservingPaymentQueue(); 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())); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.registerPaymentQueueDelegate$messageChannelSuffix', - pigeonChannelCodec, + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.registerPaymentQueueDelegate$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { try { api.registerPaymentQueueDelegate(); 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())); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.removePaymentQueueDelegate$messageChannelSuffix', - pigeonChannelCodec, + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.removePaymentQueueDelegate$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { try { api.removePaymentQueueDelegate(); 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())); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.showPriceConsentIfNeeded$messageChannelSuffix', - pigeonChannelCodec, + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.showPriceConsentIfNeeded$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(pigeonVar_channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { try { api.showPriceConsentIfNeeded(); 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())); + } + }); + } + } + { + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.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())); } }); } From 347be0aa4c4b2cd4a4f24ec03c8b48a0fd56e073 Mon Sep 17 00:00:00 2001 From: louisehsu Date: Fri, 15 Nov 2024 15:56:13 -0800 Subject: [PATCH 02/12] . --- .../test/in_app_purchase_storekit_2_platform_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 02c80b9d9be..a978db1d27b 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 @@ -36,7 +36,7 @@ void main() { InAppPurchaseStoreKitPlatform.registerPlatform(); iapStoreKitPlatform = InAppPurchasePlatform.instance as InAppPurchaseStoreKitPlatform; - iapStoreKitPlatform.enableStoreKit2(); + InAppPurchaseStoreKitPlatform.enableStoreKit2(); fakeStoreKit2Platform.reset(); }); From b40b70ca18cfee006ddbad746dd604bb99eef2f5 Mon Sep 17 00:00:00 2001 From: louisehsu Date: Fri, 15 Nov 2024 16:13:48 -0800 Subject: [PATCH 03/12] . --- .../test/fakes/fake_storekit_platform.dart | 3 +-- .../test/in_app_purchase_storekit_2_platform_test.dart | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) 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 b0a6ed35ce0..0d03162c029 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 @@ -283,8 +283,7 @@ class FakeStoreKitPlatform implements TestInAppPurchaseApi { @override bool supportsStoreKit2() { - // TODO: implement supportsStoreKit2 - throw UnimplementedError(); + return true; } } 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 a978db1d27b..7c4b762d699 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 @@ -12,6 +12,7 @@ import 'package:in_app_purchase_storekit/store_kit_2_wrappers.dart'; import 'fakes/fake_storekit_platform.dart'; import 'sk2_test_api.g.dart'; +import 'test_api.g.dart'; void main() { final SK2Product dummyProductWrapper = SK2Product( @@ -26,12 +27,16 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); final FakeStoreKit2Platform fakeStoreKit2Platform = FakeStoreKit2Platform(); + final FakeStoreKitPlatform fakeStoreKitPlatform = FakeStoreKitPlatform(); + late InAppPurchaseStoreKitPlatform iapStoreKitPlatform; setUpAll(() { TestInAppPurchase2Api.setUp(fakeStoreKit2Platform); + TestInAppPurchaseApi.setUp(fakeStoreKitPlatform); }); + setUp(() { InAppPurchaseStoreKitPlatform.registerPlatform(); iapStoreKitPlatform = From 78bf15e40d3a25b1bf818a838b631b8438495a71 Mon Sep 17 00:00:00 2001 From: louisehsu Date: Fri, 15 Nov 2024 16:27:50 -0800 Subject: [PATCH 04/12] . --- .../in_app_purchase_storekit/CHANGELOG.md | 4 ++++ .../darwin/Classes/InAppPurchasePlugin.swift | 16 +++++++++------- .../in_app_purchase_storekit/pubspec.yaml | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) 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 3d4cc8d9837..7dd881cb856 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 + +* Prevent devices below iOS 15 or macOS 15 from enabling StoreKit2. + ## 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 73fc4916642..296b862e31b 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 @@ -12,13 +12,6 @@ import StoreKit #endif public class InAppPurchasePlugin: NSObject, FlutterPlugin, FIAInAppPurchaseAPI { - public func supportsStoreKit2WithError(_ error: AutoreleasingUnsafeMutablePointer) -> NSNumber? { - if #available(iOS 15.0, macOS 15.0, *) { - return true - } - return false - } - private let receiptManager: FIAPReceiptManager private var productsCache: NSMutableDictionary = [:] private var paymentQueueDelegateCallbackChannel: FlutterMethodChannel? @@ -427,6 +420,15 @@ 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.0, macOS 15.0, *) { + return true + } + 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/pubspec.yaml b/packages/in_app_purchase/in_app_purchase_storekit/pubspec.yaml index aa3c1d7b3e6..dd15dd6062e 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 From 53ef0fa8625fc63ed8102e787c274d4ab7116944 Mon Sep 17 00:00:00 2001 From: louisehsu Date: Fri, 15 Nov 2024 16:33:21 -0800 Subject: [PATCH 05/12] . --- .../lib/src/store_kit_wrappers/sk_request_maker.dart | 1 + .../test/store_kit_wrappers/sk_methodchannel_apis_test.dart | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_wrappers/sk_request_maker.dart b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_wrappers/sk_request_maker.dart index 173d6ab6cf6..64d00922d11 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_wrappers/sk_request_maker.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_wrappers/sk_request_maker.dart @@ -56,6 +56,7 @@ class SKRequestMaker { return _hostApi.refreshReceipt(receiptProperties: receiptProperties); } + /// Check if current device supports StoreKit 2. static Future supportsStoreKit2() async { return _hostApi.supportsStoreKit2(); } 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 88d2972c296..8bd00d7de93 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 @@ -307,8 +307,7 @@ class FakeStoreKitPlatform implements TestInAppPurchaseApi { @override bool supportsStoreKit2() { - // TODO: implement supportsStoreKit2 - throw UnimplementedError(); + return true; } } From cc75f7b5ff679e43a8a0f9803a38b432770baba3 Mon Sep 17 00:00:00 2001 From: louisehsu Date: Fri, 15 Nov 2024 16:48:49 -0800 Subject: [PATCH 06/12] format --- .../darwin/Classes/messages.g.h | 10 +- .../darwin/Classes/messages.g.m | 420 +++++++++++------- .../lib/src/messages.g.dart | 208 +++++---- ...app_purchase_storekit_2_platform_test.dart | 1 - .../test/test_api.g.dart | 417 +++++++++++------ 5 files changed, 674 insertions(+), 382 deletions(-) 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 e61fbf612f7..9cb8b408575 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 @@ -67,7 +67,8 @@ 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, @@ -274,8 +275,11 @@ NSObject *FIAGetMessagesCodec(void); - (nullable NSNumber *)supportsStoreKit2WithError:(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 c3ad1f414d7..50963e67039 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 @@ -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); @@ -174,12 +175,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; @@ -214,10 +215,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; @@ -244,11 +245,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; @@ -280,9 +281,8 @@ + (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,16 +330,17 @@ + (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; @@ -384,9 +385,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; @@ -413,13 +414,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; @@ -434,11 +435,13 @@ + (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; } @@ -459,17 +462,20 @@ + (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; } @@ -491,39 +497,47 @@ - (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]; @@ -544,7 +558,8 @@ - (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]]) { @@ -602,26 +617,37 @@ - (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]; @@ -632,13 +658,18 @@ 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]; @@ -649,13 +680,17 @@ 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]; @@ -666,13 +701,18 @@ 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); @@ -685,32 +725,45 @@ 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); @@ -723,13 +776,18 @@ 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); @@ -742,13 +800,18 @@ 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]; @@ -759,13 +822,18 @@ 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]; @@ -776,32 +844,43 @@ 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]; @@ -812,13 +891,18 @@ 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]; @@ -829,13 +913,18 @@ 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]; @@ -846,13 +935,18 @@ 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]; @@ -863,13 +957,18 @@ 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]; @@ -880,13 +979,18 @@ void SetUpFIAInAppPurchaseAPIWithSuffix(id binaryMesseng } } { - FlutterBasicMessageChannel *channel = - [[FlutterBasicMessageChannel alloc] - initWithName:[NSString stringWithFormat:@"%@%@", @"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.supportsStoreKit2", messageChannelSuffix] + FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] + initWithName:[NSString stringWithFormat:@"%@%@", + @"dev.flutter.pigeon.in_app_purchase_storekit." + @"InAppPurchaseAPI.supportsStoreKit2", + messageChannelSuffix] binaryMessenger:binaryMessenger - codec:FIAGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(supportsStoreKit2WithError:)], @"FIAInAppPurchaseAPI api (%@) doesn't respond to @selector(supportsStoreKit2WithError:)", api); + NSCAssert( + [api respondsToSelector:@selector(supportsStoreKit2WithError:)], + @"FIAInAppPurchaseAPI api (%@) doesn't respond to @selector(supportsStoreKit2WithError:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { FlutterError *error; NSNumber *output = [api supportsStoreKit2WithError:&error]; 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 48b8ae8997e..f5938cf3c25 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 @@ -18,7 +18,8 @@ PlatformException _createConnectionError(String channelName) { ); } -List wrapResponse({Object? result, PlatformException? error, bool empty = false}) { +List wrapResponse( + {Object? result, PlatformException? error, bool empty = false}) { if (empty) { return []; } @@ -35,27 +36,32 @@ enum SKPaymentTransactionStateMessage { /// transaction to update to another state. Never complete a transaction that /// is still in a purchasing state. purchasing, + /// The user's payment has been succesfully processed. /// /// You should provide the user the content that they purchased. purchased, + /// The transaction failed. /// /// Check the [PaymentTransactionWrapper.error] property from /// [PaymentTransactionWrapper] for details. failed, + /// This transaction is restoring content previously purchased by the user. /// /// The previous transaction information can be obtained in /// [PaymentTransactionWrapper.originalTransaction] from /// [PaymentTransactionWrapper]. restored, + /// The transaction is in the queue but pending external action. Wait for /// another callback to get the final state. /// /// You should update your UI to indicate that you are waiting for the /// transaction to update to another state. deferred, + /// Indicates the transaction is in an unspecified state. unspecified, } @@ -63,6 +69,7 @@ enum SKPaymentTransactionStateMessage { enum SKProductDiscountTypeMessage { /// A constant indicating the discount type is an introductory offer. introductory, + /// A constant indicating the discount type is a promotional offer. subscription, } @@ -70,10 +77,13 @@ enum SKProductDiscountTypeMessage { enum SKProductDiscountPaymentModeMessage { /// Allows user to pay the discounted price at each payment period. payAsYouGo, + /// Allows user to pay the discounted price upfront and receive the product for the rest of time that was paid for. payUpFront, + /// User pays nothing during the discounted period. freeTrial, + /// Unspecified mode. unspecified, } @@ -357,7 +367,8 @@ class SKProductMessage { price: result[5]! as String, subscriptionPeriod: result[6] as SKProductSubscriptionPeriodMessage?, introductoryPrice: result[7] as SKProductDiscountMessage?, - discounts: (result[8] as List?)?.cast(), + discounts: + (result[8] as List?)?.cast(), ); } } @@ -473,7 +484,6 @@ class SKProductSubscriptionPeriodMessage { } } - class _PigeonCodec extends StandardMessageCodec { const _PigeonCodec(); @override @@ -481,46 +491,46 @@ class _PigeonCodec extends StandardMessageCodec { if (value is int) { buffer.putUint8(4); buffer.putInt64(value); - } else if (value is SKPaymentTransactionStateMessage) { + } else if (value is SKPaymentTransactionStateMessage) { buffer.putUint8(129); writeValue(buffer, value.index); - } else if (value is SKProductDiscountTypeMessage) { + } else if (value is SKProductDiscountTypeMessage) { buffer.putUint8(130); writeValue(buffer, value.index); - } else if (value is SKProductDiscountPaymentModeMessage) { + } else if (value is SKProductDiscountPaymentModeMessage) { buffer.putUint8(131); writeValue(buffer, value.index); - } else if (value is SKSubscriptionPeriodUnitMessage) { + } else if (value is SKSubscriptionPeriodUnitMessage) { buffer.putUint8(132); writeValue(buffer, value.index); - } else if (value is SKPaymentTransactionMessage) { + } else if (value is SKPaymentTransactionMessage) { buffer.putUint8(133); writeValue(buffer, value.encode()); - } else if (value is SKPaymentMessage) { + } else if (value is SKPaymentMessage) { buffer.putUint8(134); writeValue(buffer, value.encode()); - } else if (value is SKErrorMessage) { + } else if (value is SKErrorMessage) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else if (value is SKPaymentDiscountMessage) { + } else if (value is SKPaymentDiscountMessage) { buffer.putUint8(136); writeValue(buffer, value.encode()); - } else if (value is SKStorefrontMessage) { + } else if (value is SKStorefrontMessage) { buffer.putUint8(137); writeValue(buffer, value.encode()); - } else if (value is SKProductsResponseMessage) { + } else if (value is SKProductsResponseMessage) { buffer.putUint8(138); writeValue(buffer, value.encode()); - } else if (value is SKProductMessage) { + } else if (value is SKProductMessage) { buffer.putUint8(139); writeValue(buffer, value.encode()); - } else if (value is SKPriceLocaleMessage) { + } else if (value is SKPriceLocaleMessage) { buffer.putUint8(140); writeValue(buffer, value.encode()); - } else if (value is SKProductDiscountMessage) { + } else if (value is SKProductDiscountMessage) { buffer.putUint8(141); writeValue(buffer, value.encode()); - } else if (value is SKProductSubscriptionPeriodMessage) { + } else if (value is SKProductSubscriptionPeriodMessage) { buffer.putUint8(142); writeValue(buffer, value.encode()); } else { @@ -531,37 +541,45 @@ class _PigeonCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 129: + case 129: final int? value = readValue(buffer) as int?; - return value == null ? null : SKPaymentTransactionStateMessage.values[value]; - case 130: + return value == null + ? null + : SKPaymentTransactionStateMessage.values[value]; + case 130: final int? value = readValue(buffer) as int?; - return value == null ? null : SKProductDiscountTypeMessage.values[value]; - case 131: + return value == null + ? null + : SKProductDiscountTypeMessage.values[value]; + case 131: final int? value = readValue(buffer) as int?; - return value == null ? null : SKProductDiscountPaymentModeMessage.values[value]; - case 132: + return value == null + ? null + : SKProductDiscountPaymentModeMessage.values[value]; + case 132: final int? value = readValue(buffer) as int?; - return value == null ? null : SKSubscriptionPeriodUnitMessage.values[value]; - case 133: + return value == null + ? null + : SKSubscriptionPeriodUnitMessage.values[value]; + case 133: return SKPaymentTransactionMessage.decode(readValue(buffer)!); - case 134: + case 134: return SKPaymentMessage.decode(readValue(buffer)!); - case 135: + case 135: return SKErrorMessage.decode(readValue(buffer)!); - case 136: + case 136: return SKPaymentDiscountMessage.decode(readValue(buffer)!); - case 137: + case 137: return SKStorefrontMessage.decode(readValue(buffer)!); - case 138: + case 138: return SKProductsResponseMessage.decode(readValue(buffer)!); - case 139: + case 139: return SKProductMessage.decode(readValue(buffer)!); - case 140: + case 140: return SKPriceLocaleMessage.decode(readValue(buffer)!); - case 141: + case 141: return SKProductDiscountMessage.decode(readValue(buffer)!); - case 142: + case 142: return SKProductSubscriptionPeriodMessage.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -573,9 +591,11 @@ class InAppPurchaseAPI { /// Constructor for [InAppPurchaseAPI]. 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. - InAppPurchaseAPI({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) + InAppPurchaseAPI( + {BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) : pigeonVar_binaryMessenger = binaryMessenger, - pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + pigeonVar_messageChannelSuffix = + messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; final BinaryMessenger? pigeonVar_binaryMessenger; static const MessageCodec pigeonChannelCodec = _PigeonCodec(); @@ -584,8 +604,10 @@ class InAppPurchaseAPI { /// Returns if the current device is able to make payments Future canMakePayments() async { - final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.canMakePayments$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.canMakePayments$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, @@ -611,8 +633,10 @@ class InAppPurchaseAPI { } Future> transactions() async { - final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.transactions$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.transactions$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, @@ -633,13 +657,16 @@ class InAppPurchaseAPI { message: 'Host platform returned null value for non-null return value.', ); } else { - return (pigeonVar_replyList[0] as List?)!.cast(); + return (pigeonVar_replyList[0] as List?)! + .cast(); } } Future storefront() async { - final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.storefront$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.storefront$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, @@ -665,8 +692,10 @@ class InAppPurchaseAPI { } Future addPayment(Map paymentMap) async { - final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.addPayment$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.addPayment$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, @@ -686,15 +715,18 @@ class InAppPurchaseAPI { } } - Future startProductRequest(List productIdentifiers) async { - final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startProductRequest$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + Future startProductRequest( + List productIdentifiers) async { + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startProductRequest$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final List? pigeonVar_replyList = - await pigeonVar_channel.send([productIdentifiers]) as List?; + final List? pigeonVar_replyList = await pigeonVar_channel + .send([productIdentifiers]) as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -714,8 +746,10 @@ class InAppPurchaseAPI { } Future finishTransaction(Map finishMap) async { - final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.finishTransaction$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.finishTransaction$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, @@ -736,14 +770,16 @@ class InAppPurchaseAPI { } Future restoreTransactions(String? applicationUserName) async { - final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.restoreTransactions$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.restoreTransactions$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final List? pigeonVar_replyList = - await pigeonVar_channel.send([applicationUserName]) as List?; + final List? pigeonVar_replyList = await pigeonVar_channel + .send([applicationUserName]) as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -758,8 +794,10 @@ class InAppPurchaseAPI { } Future presentCodeRedemptionSheet() async { - final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.presentCodeRedemptionSheet$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.presentCodeRedemptionSheet$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, @@ -780,8 +818,10 @@ class InAppPurchaseAPI { } Future retrieveReceiptData() async { - final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.retrieveReceiptData$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.retrieveReceiptData$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, @@ -802,14 +842,16 @@ class InAppPurchaseAPI { } Future refreshReceipt({Map? receiptProperties}) async { - final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.refreshReceipt$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.refreshReceipt$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final List? pigeonVar_replyList = - await pigeonVar_channel.send([receiptProperties]) as List?; + final List? pigeonVar_replyList = await pigeonVar_channel + .send([receiptProperties]) as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -824,8 +866,10 @@ class InAppPurchaseAPI { } Future startObservingPaymentQueue() async { - final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startObservingPaymentQueue$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startObservingPaymentQueue$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, @@ -846,8 +890,10 @@ class InAppPurchaseAPI { } Future stopObservingPaymentQueue() async { - final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.stopObservingPaymentQueue$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.stopObservingPaymentQueue$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, @@ -868,8 +914,10 @@ class InAppPurchaseAPI { } Future registerPaymentQueueDelegate() async { - final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.registerPaymentQueueDelegate$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.registerPaymentQueueDelegate$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, @@ -890,8 +938,10 @@ class InAppPurchaseAPI { } Future removePaymentQueueDelegate() async { - final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.removePaymentQueueDelegate$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.removePaymentQueueDelegate$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, @@ -912,8 +962,10 @@ class InAppPurchaseAPI { } Future showPriceConsentIfNeeded() async { - final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.showPriceConsentIfNeeded$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.showPriceConsentIfNeeded$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, @@ -934,8 +986,10 @@ class InAppPurchaseAPI { } Future supportsStoreKit2() async { - final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.supportsStoreKit2$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.supportsStoreKit2$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = + BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, 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 6d1757f44ad..658932e7ce6 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 @@ -36,7 +36,6 @@ void main() { TestInAppPurchaseApi.setUp(fakeStoreKitPlatform); }); - setUp(() { InAppPurchaseStoreKitPlatform.registerPlatform(); iapStoreKitPlatform = 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 963dcdb3dce..916b37ef1ba 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 @@ -13,7 +13,6 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:in_app_purchase_storekit/src/messages.g.dart'; - class _PigeonCodec extends StandardMessageCodec { const _PigeonCodec(); @override @@ -21,46 +20,46 @@ class _PigeonCodec extends StandardMessageCodec { if (value is int) { buffer.putUint8(4); buffer.putInt64(value); - } else if (value is SKPaymentTransactionStateMessage) { + } else if (value is SKPaymentTransactionStateMessage) { buffer.putUint8(129); writeValue(buffer, value.index); - } else if (value is SKProductDiscountTypeMessage) { + } else if (value is SKProductDiscountTypeMessage) { buffer.putUint8(130); writeValue(buffer, value.index); - } else if (value is SKProductDiscountPaymentModeMessage) { + } else if (value is SKProductDiscountPaymentModeMessage) { buffer.putUint8(131); writeValue(buffer, value.index); - } else if (value is SKSubscriptionPeriodUnitMessage) { + } else if (value is SKSubscriptionPeriodUnitMessage) { buffer.putUint8(132); writeValue(buffer, value.index); - } else if (value is SKPaymentTransactionMessage) { + } else if (value is SKPaymentTransactionMessage) { buffer.putUint8(133); writeValue(buffer, value.encode()); - } else if (value is SKPaymentMessage) { + } else if (value is SKPaymentMessage) { buffer.putUint8(134); writeValue(buffer, value.encode()); - } else if (value is SKErrorMessage) { + } else if (value is SKErrorMessage) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else if (value is SKPaymentDiscountMessage) { + } else if (value is SKPaymentDiscountMessage) { buffer.putUint8(136); writeValue(buffer, value.encode()); - } else if (value is SKStorefrontMessage) { + } else if (value is SKStorefrontMessage) { buffer.putUint8(137); writeValue(buffer, value.encode()); - } else if (value is SKProductsResponseMessage) { + } else if (value is SKProductsResponseMessage) { buffer.putUint8(138); writeValue(buffer, value.encode()); - } else if (value is SKProductMessage) { + } else if (value is SKProductMessage) { buffer.putUint8(139); writeValue(buffer, value.encode()); - } else if (value is SKPriceLocaleMessage) { + } else if (value is SKPriceLocaleMessage) { buffer.putUint8(140); writeValue(buffer, value.encode()); - } else if (value is SKProductDiscountMessage) { + } else if (value is SKProductDiscountMessage) { buffer.putUint8(141); writeValue(buffer, value.encode()); - } else if (value is SKProductSubscriptionPeriodMessage) { + } else if (value is SKProductSubscriptionPeriodMessage) { buffer.putUint8(142); writeValue(buffer, value.encode()); } else { @@ -71,37 +70,45 @@ class _PigeonCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 129: + case 129: final int? value = readValue(buffer) as int?; - return value == null ? null : SKPaymentTransactionStateMessage.values[value]; - case 130: + return value == null + ? null + : SKPaymentTransactionStateMessage.values[value]; + case 130: final int? value = readValue(buffer) as int?; - return value == null ? null : SKProductDiscountTypeMessage.values[value]; - case 131: + return value == null + ? null + : SKProductDiscountTypeMessage.values[value]; + case 131: final int? value = readValue(buffer) as int?; - return value == null ? null : SKProductDiscountPaymentModeMessage.values[value]; - case 132: + return value == null + ? null + : SKProductDiscountPaymentModeMessage.values[value]; + case 132: final int? value = readValue(buffer) as int?; - return value == null ? null : SKSubscriptionPeriodUnitMessage.values[value]; - case 133: + return value == null + ? null + : SKSubscriptionPeriodUnitMessage.values[value]; + case 133: return SKPaymentTransactionMessage.decode(readValue(buffer)!); - case 134: + case 134: return SKPaymentMessage.decode(readValue(buffer)!); - case 135: + case 135: return SKErrorMessage.decode(readValue(buffer)!); - case 136: + case 136: return SKPaymentDiscountMessage.decode(readValue(buffer)!); - case 137: + case 137: return SKStorefrontMessage.decode(readValue(buffer)!); - case 138: + case 138: return SKProductsResponseMessage.decode(readValue(buffer)!); - case 139: + case 139: return SKProductMessage.decode(readValue(buffer)!); - case 140: + case 140: return SKPriceLocaleMessage.decode(readValue(buffer)!); - case 141: + case 141: return SKProductDiscountMessage.decode(readValue(buffer)!); - case 142: + case 142: return SKProductSubscriptionPeriodMessage.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -110,7 +117,8 @@ class _PigeonCodec extends StandardMessageCodec { } abstract class TestInAppPurchaseApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec pigeonChannelCodec = _PigeonCodec(); /// Returns if the current device is able to make payments @@ -122,7 +130,8 @@ abstract class TestInAppPurchaseApi { void addPayment(Map paymentMap); - Future startProductRequest(List productIdentifiers); + Future startProductRequest( + List productIdentifiers); void finishTransaction(Map finishMap); @@ -146,77 +155,110 @@ abstract class TestInAppPurchaseApi { bool supportsStoreKit2(); - static void setUp(TestInAppPurchaseApi? api, {BinaryMessenger? binaryMessenger, String messageChannelSuffix = '',}) { - messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + static void setUp( + TestInAppPurchaseApi? api, { + BinaryMessenger? binaryMessenger, + String messageChannelSuffix = '', + }) { + messageChannelSuffix = + messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; { - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.canMakePayments$messageChannelSuffix', pigeonChannelCodec, + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.canMakePayments$messageChannelSuffix', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, + (Object? message) async { try { final bool output = api.canMakePayments(); return [output]; } 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())); } }); } } { - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.transactions$messageChannelSuffix', pigeonChannelCodec, + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.transactions$messageChannelSuffix', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, + (Object? message) async { try { final List output = api.transactions(); return [output]; } 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())); } }); } } { - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.storefront$messageChannelSuffix', pigeonChannelCodec, + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.storefront$messageChannelSuffix', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, + (Object? message) async { try { final SKStorefrontMessage output = api.storefront(); return [output]; } 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())); } }); } } { - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.addPayment$messageChannelSuffix', pigeonChannelCodec, + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.addPayment$messageChannelSuffix', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.addPayment was null.'); + 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.addPayment was null.'); final List args = (message as List?)!; - final Map? arg_paymentMap = (args[0] as Map?)?.cast(); + final Map? arg_paymentMap = + (args[0] as Map?)?.cast(); assert(arg_paymentMap != null, 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.addPayment was null, expected non-null Map.'); try { @@ -224,49 +266,66 @@ abstract class TestInAppPurchaseApi { 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())); } }); } } { - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startProductRequest$messageChannelSuffix', pigeonChannelCodec, + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startProductRequest$messageChannelSuffix', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startProductRequest was null.'); + 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startProductRequest was null.'); final List args = (message as List?)!; - final List? arg_productIdentifiers = (args[0] as List?)?.cast(); + final List? arg_productIdentifiers = + (args[0] as List?)?.cast(); assert(arg_productIdentifiers != null, 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startProductRequest was null, expected non-null List.'); try { - final SKProductsResponseMessage output = await api.startProductRequest(arg_productIdentifiers!); + final SKProductsResponseMessage output = + await api.startProductRequest(arg_productIdentifiers!); return [output]; } 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())); } }); } } { - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.finishTransaction$messageChannelSuffix', pigeonChannelCodec, + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.finishTransaction$messageChannelSuffix', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.finishTransaction was null.'); + 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.finishTransaction was null.'); final List args = (message as List?)!; - final Map? arg_finishMap = (args[0] as Map?)?.cast(); + final Map? arg_finishMap = + (args[0] as Map?)?.cast(); assert(arg_finishMap != null, 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.finishTransaction was null, expected non-null Map.'); try { @@ -274,22 +333,29 @@ abstract class TestInAppPurchaseApi { 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())); } }); } } { - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.restoreTransactions$messageChannelSuffix', pigeonChannelCodec, + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.restoreTransactions$messageChannelSuffix', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.restoreTransactions was null.'); + 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.restoreTransactions was null.'); final List args = (message as List?)!; final String? arg_applicationUserName = (args[0] as String?); try { @@ -297,183 +363,248 @@ abstract class TestInAppPurchaseApi { 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())); } }); } } { - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.presentCodeRedemptionSheet$messageChannelSuffix', pigeonChannelCodec, + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.presentCodeRedemptionSheet$messageChannelSuffix', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, + (Object? message) async { try { api.presentCodeRedemptionSheet(); 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())); } }); } } { - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.retrieveReceiptData$messageChannelSuffix', pigeonChannelCodec, + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.retrieveReceiptData$messageChannelSuffix', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, + (Object? message) async { try { final String? output = api.retrieveReceiptData(); return [output]; } 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())); } }); } } { - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.refreshReceipt$messageChannelSuffix', pigeonChannelCodec, + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.refreshReceipt$messageChannelSuffix', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.refreshReceipt was null.'); + 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.refreshReceipt was null.'); final List args = (message as List?)!; - final Map? arg_receiptProperties = (args[0] as Map?)?.cast(); + final Map? arg_receiptProperties = + (args[0] as Map?)?.cast(); try { await api.refreshReceipt(receiptProperties: arg_receiptProperties); 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())); } }); } } { - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startObservingPaymentQueue$messageChannelSuffix', pigeonChannelCodec, + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startObservingPaymentQueue$messageChannelSuffix', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, + (Object? message) async { try { api.startObservingPaymentQueue(); 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())); } }); } } { - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.stopObservingPaymentQueue$messageChannelSuffix', pigeonChannelCodec, + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.stopObservingPaymentQueue$messageChannelSuffix', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, + (Object? message) async { try { api.stopObservingPaymentQueue(); 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())); } }); } } { - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.registerPaymentQueueDelegate$messageChannelSuffix', pigeonChannelCodec, + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.registerPaymentQueueDelegate$messageChannelSuffix', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, + (Object? message) async { try { api.registerPaymentQueueDelegate(); 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())); } }); } } { - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.removePaymentQueueDelegate$messageChannelSuffix', pigeonChannelCodec, + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.removePaymentQueueDelegate$messageChannelSuffix', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, + (Object? message) async { try { api.removePaymentQueueDelegate(); 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())); } }); } } { - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.showPriceConsentIfNeeded$messageChannelSuffix', pigeonChannelCodec, + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.showPriceConsentIfNeeded$messageChannelSuffix', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, + (Object? message) async { try { api.showPriceConsentIfNeeded(); 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())); } }); } } { - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.supportsStoreKit2$messageChannelSuffix', pigeonChannelCodec, + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< + Object?>( + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.supportsStoreKit2$messageChannelSuffix', + pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { + _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())); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString())); } }); } From a99f3b8ef9af0cc7ac391b9fd6ed3e41575cd3f7 Mon Sep 17 00:00:00 2001 From: louisehsu Date: Fri, 15 Nov 2024 17:15:53 -0800 Subject: [PATCH 07/12] . --- .../darwin/Classes/messages.g.h | 263 +++++++++++------- 1 file changed, 157 insertions(+), 106 deletions(-) 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 9cb8b408575..20228423800 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 @@ -67,7 +67,8 @@ 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 + /// 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. @@ -110,140 +111,162 @@ 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; -@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; + 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; @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; ++ (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; @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; + 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; ++ (instancetype)makeWithProducts: + (nullable NSArray *)products + 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 @@ -254,32 +277,60 @@ NSObject *FIAGetMessagesCodec(void); /// Returns if the current device is able to make payments /// /// @return `nil` only when `error != nil`. -- (nullable NSNumber *)canMakePaymentsWithError:(FlutterError *_Nullable *_Nonnull)error; +- (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)presentCodeRedemptionSheetWithError:(FlutterError *_Nullable *_Nonnull)error; -- (nullable NSString *)retrieveReceiptDataWithError:(FlutterError *_Nullable *_Nonnull)error; -- (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; -- (void)removePaymentQueueDelegateWithError:(FlutterError *_Nullable *_Nonnull)error; -- (void)showPriceConsentIfNeededWithError:(FlutterError *_Nullable *_Nonnull)error; +- (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)presentCodeRedemptionSheetWithError: + (FlutterError *_Nullable *_Nonnull)error; +- (nullable NSString *)retrieveReceiptDataWithError: + (FlutterError *_Nullable *_Nonnull)error; +- (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; +- (void)removePaymentQueueDelegateWithError: + (FlutterError *_Nullable *_Nonnull)error; +- (void)showPriceConsentIfNeededWithError: + (FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable NSNumber *)supportsStoreKit2WithError:(FlutterError *_Nullable *_Nonnull)error; +- (nullable NSNumber *)supportsStoreKit2WithError: + (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 From 5427d18e4ef8a30aeb879f537a5b7ff620e96c66 Mon Sep 17 00:00:00 2001 From: louisehsu Date: Mon, 18 Nov 2024 14:08:21 -0800 Subject: [PATCH 08/12] . --- .../darwin/Classes/messages.g.h | 70 +++++++------------ 1 file changed, 24 insertions(+), 46 deletions(-) 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 20228423800..5f73682f661 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 @@ -111,18 +111,14 @@ 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 + 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, 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; @@ -131,21 +127,18 @@ typedef NS_ENUM(NSUInteger, FIASKSubscriptionPeriodUnitMessage) { @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; ++ (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; +@property(nonatomic, strong, nullable) FIASKPaymentDiscountMessage *paymentDiscount; @end @interface FIASKErrorMessage : NSObject @@ -177,20 +170,16 @@ typedef NS_ENUM(NSUInteger, FIASKSubscriptionPeriodUnitMessage) { @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; ++ (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; ++ (instancetype)makeWithProducts:(nullable NSArray *)products + invalidProductIdentifiers:(nullable NSArray *)invalidProductIdentifiers; @property(nonatomic, copy, nullable) NSArray *products; -@property(nonatomic, copy, nullable) - NSArray *invalidProductIdentifiers; +@property(nonatomic, copy, nullable) NSArray *invalidProductIdentifiers; @end @interface FIASKProductMessage : NSObject @@ -203,26 +192,18 @@ typedef NS_ENUM(NSUInteger, FIASKSubscriptionPeriodUnitMessage) { priceLocale:(FIASKPriceLocaleMessage *)priceLocale subscriptionGroupIdentifier:(nullable NSString *)subscriptionGroupIdentifier price:(NSString *)price - subscriptionPeriod: - (nullable FIASKProductSubscriptionPeriodMessage *) - subscriptionPeriod - introductoryPrice: - (nullable FIASKProductDiscountMessage *)introductoryPrice - discounts: - (nullable NSArray *) - discounts; + 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; +@property(nonatomic, strong, nullable) FIASKProductSubscriptionPeriodMessage *subscriptionPeriod; +@property(nonatomic, strong, nullable) FIASKProductDiscountMessage *introductoryPrice; +@property(nonatomic, copy, nullable) NSArray *discounts; @end @interface FIASKPriceLocaleMessage : NSObject @@ -245,18 +226,15 @@ typedef NS_ENUM(NSUInteger, FIASKSubscriptionPeriodUnitMessage) { + (instancetype)makeWithPrice:(NSString *)price priceLocale:(FIASKPriceLocaleMessage *)priceLocale numberOfPeriods:(NSInteger)numberOfPeriods - paymentMode: - (FIASKProductDiscountPaymentModeMessage)paymentMode - subscriptionPeriod: - (FIASKProductSubscriptionPeriodMessage *)subscriptionPeriod + 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, strong) FIASKProductSubscriptionPeriodMessage *subscriptionPeriod; @property(nonatomic, copy, nullable) NSString *identifier; @property(nonatomic, assign) FIASKProductDiscountTypeMessage type; @end From 06194b0b6042c701dca41758bc06d354aae6f7fc Mon Sep 17 00:00:00 2001 From: louisehsu Date: Mon, 18 Nov 2024 15:23:35 -0800 Subject: [PATCH 09/12] . --- .../darwin/Classes/messages.g.h | 70 ++++++++++++------- 1 file changed, 46 insertions(+), 24 deletions(-) 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 5f73682f661..20228423800 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 @@ -111,14 +111,18 @@ 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 + 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, 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; @@ -127,18 +131,21 @@ typedef NS_ENUM(NSUInteger, FIASKSubscriptionPeriodUnitMessage) { @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; ++ (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; +@property(nonatomic, strong, nullable) + FIASKPaymentDiscountMessage *paymentDiscount; @end @interface FIASKErrorMessage : NSObject @@ -170,16 +177,20 @@ typedef NS_ENUM(NSUInteger, FIASKSubscriptionPeriodUnitMessage) { @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; ++ (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; ++ (instancetype)makeWithProducts: + (nullable NSArray *)products + invalidProductIdentifiers: + (nullable NSArray *)invalidProductIdentifiers; @property(nonatomic, copy, nullable) NSArray *products; -@property(nonatomic, copy, nullable) NSArray *invalidProductIdentifiers; +@property(nonatomic, copy, nullable) + NSArray *invalidProductIdentifiers; @end @interface FIASKProductMessage : NSObject @@ -192,18 +203,26 @@ typedef NS_ENUM(NSUInteger, FIASKSubscriptionPeriodUnitMessage) { priceLocale:(FIASKPriceLocaleMessage *)priceLocale subscriptionGroupIdentifier:(nullable NSString *)subscriptionGroupIdentifier price:(NSString *)price - subscriptionPeriod:(nullable FIASKProductSubscriptionPeriodMessage *)subscriptionPeriod - introductoryPrice:(nullable FIASKProductDiscountMessage *)introductoryPrice - discounts:(nullable NSArray *)discounts; + 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; +@property(nonatomic, strong, nullable) + FIASKProductSubscriptionPeriodMessage *subscriptionPeriod; +@property(nonatomic, strong, nullable) + FIASKProductDiscountMessage *introductoryPrice; +@property(nonatomic, copy, nullable) + NSArray *discounts; @end @interface FIASKPriceLocaleMessage : NSObject @@ -226,15 +245,18 @@ typedef NS_ENUM(NSUInteger, FIASKSubscriptionPeriodUnitMessage) { + (instancetype)makeWithPrice:(NSString *)price priceLocale:(FIASKPriceLocaleMessage *)priceLocale numberOfPeriods:(NSInteger)numberOfPeriods - paymentMode:(FIASKProductDiscountPaymentModeMessage)paymentMode - subscriptionPeriod:(FIASKProductSubscriptionPeriodMessage *)subscriptionPeriod + 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, strong) + FIASKProductSubscriptionPeriodMessage *subscriptionPeriod; @property(nonatomic, copy, nullable) NSString *identifier; @property(nonatomic, assign) FIASKProductDiscountTypeMessage type; @end From da953a27c76ddf735da5a3b8496d97b0b7b26fc8 Mon Sep 17 00:00:00 2001 From: louisehsu Date: Tue, 19 Nov 2024 11:12:08 -0800 Subject: [PATCH 10/12] . --- .../darwin/Classes/messages.g.h | 70 +++++++------------ 1 file changed, 24 insertions(+), 46 deletions(-) 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 20228423800..5f73682f661 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 @@ -111,18 +111,14 @@ 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 + 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, 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; @@ -131,21 +127,18 @@ typedef NS_ENUM(NSUInteger, FIASKSubscriptionPeriodUnitMessage) { @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; ++ (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; +@property(nonatomic, strong, nullable) FIASKPaymentDiscountMessage *paymentDiscount; @end @interface FIASKErrorMessage : NSObject @@ -177,20 +170,16 @@ typedef NS_ENUM(NSUInteger, FIASKSubscriptionPeriodUnitMessage) { @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; ++ (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; ++ (instancetype)makeWithProducts:(nullable NSArray *)products + invalidProductIdentifiers:(nullable NSArray *)invalidProductIdentifiers; @property(nonatomic, copy, nullable) NSArray *products; -@property(nonatomic, copy, nullable) - NSArray *invalidProductIdentifiers; +@property(nonatomic, copy, nullable) NSArray *invalidProductIdentifiers; @end @interface FIASKProductMessage : NSObject @@ -203,26 +192,18 @@ typedef NS_ENUM(NSUInteger, FIASKSubscriptionPeriodUnitMessage) { priceLocale:(FIASKPriceLocaleMessage *)priceLocale subscriptionGroupIdentifier:(nullable NSString *)subscriptionGroupIdentifier price:(NSString *)price - subscriptionPeriod: - (nullable FIASKProductSubscriptionPeriodMessage *) - subscriptionPeriod - introductoryPrice: - (nullable FIASKProductDiscountMessage *)introductoryPrice - discounts: - (nullable NSArray *) - discounts; + 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; +@property(nonatomic, strong, nullable) FIASKProductSubscriptionPeriodMessage *subscriptionPeriod; +@property(nonatomic, strong, nullable) FIASKProductDiscountMessage *introductoryPrice; +@property(nonatomic, copy, nullable) NSArray *discounts; @end @interface FIASKPriceLocaleMessage : NSObject @@ -245,18 +226,15 @@ typedef NS_ENUM(NSUInteger, FIASKSubscriptionPeriodUnitMessage) { + (instancetype)makeWithPrice:(NSString *)price priceLocale:(FIASKPriceLocaleMessage *)priceLocale numberOfPeriods:(NSInteger)numberOfPeriods - paymentMode: - (FIASKProductDiscountPaymentModeMessage)paymentMode - subscriptionPeriod: - (FIASKProductSubscriptionPeriodMessage *)subscriptionPeriod + 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, strong) FIASKProductSubscriptionPeriodMessage *subscriptionPeriod; @property(nonatomic, copy, nullable) NSString *identifier; @property(nonatomic, assign) FIASKProductDiscountTypeMessage type; @end From dad159c8d853f45140df5759eab3a3d27fa99ca4 Mon Sep 17 00:00:00 2001 From: louisehsu Date: Tue, 19 Nov 2024 11:31:25 -0800 Subject: [PATCH 11/12] ugh --- .../darwin/Classes/messages.g.h | 65 +++++++------------ 1 file changed, 22 insertions(+), 43 deletions(-) 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 5f73682f661..3ec07a94628 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 @@ -255,60 +255,39 @@ NSObject *FIAGetMessagesCodec(void); /// Returns if the current device is able to make payments /// /// @return `nil` only when `error != nil`. -- (nullable NSNumber *)canMakePaymentsWithError: - (FlutterError *_Nullable *_Nonnull)error; +- (nullable NSNumber *)canMakePaymentsWithError:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. - (nullable NSArray *)transactionsWithError: (FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable FIASKStorefrontMessage *)storefrontWithError: - (FlutterError *_Nullable *_Nonnull)error; +- (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)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)startObservingPaymentQueueWithError: - (FlutterError *_Nullable *_Nonnull)error; -- (void)stopObservingPaymentQueueWithError: - (FlutterError *_Nullable *_Nonnull)error; -- (void)registerPaymentQueueDelegateWithError: - (FlutterError *_Nullable *_Nonnull)error; -- (void)removePaymentQueueDelegateWithError: - (FlutterError *_Nullable *_Nonnull)error; -- (void)showPriceConsentIfNeededWithError: - (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)startObservingPaymentQueueWithError:(FlutterError *_Nullable *_Nonnull)error; +- (void)stopObservingPaymentQueueWithError:(FlutterError *_Nullable *_Nonnull)error; +- (void)registerPaymentQueueDelegateWithError:(FlutterError *_Nullable *_Nonnull)error; +- (void)removePaymentQueueDelegateWithError:(FlutterError *_Nullable *_Nonnull)error; +- (void)showPriceConsentIfNeededWithError:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable NSNumber *)supportsStoreKit2WithError: - (FlutterError *_Nullable *_Nonnull)error; +- (nullable NSNumber *)supportsStoreKit2WithError:(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 From 9dfd6299d9eb6196096f590a8c604a2021eaa93f Mon Sep 17 00:00:00 2001 From: louisehsu Date: Tue, 19 Nov 2024 14:08:31 -0800 Subject: [PATCH 12/12] add comment --- .../darwin/Classes/InAppPurchasePlugin.swift | 2 +- .../lib/src/in_app_purchase_storekit_platform.dart | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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 296b862e31b..089f1c5ca53 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 @@ -423,7 +423,7 @@ public class InAppPurchasePlugin: NSObject, FlutterPlugin, FIAInAppPurchaseAPI { public func supportsStoreKit2WithError(_ error: AutoreleasingUnsafeMutablePointer) -> NSNumber? { - if #available(iOS 15.0, macOS 15.0, *) { + if #available(iOS 15.0, macOS 12.0, *) { return true } return false 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 af3bd190370..51787d9c642 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,6 +249,7 @@ class InAppPurchaseStoreKitPlatform extends InAppPurchasePlatform { Future getCountryCode() => countryCode(); /// Turns on StoreKit2. You cannot disable this after it is enabled. + /// This can only be enabled if your device supports StoreKit 2. static Future enableStoreKit2() async { _useStoreKit2 = await SKRequestMaker.supportsStoreKit2(); return _useStoreKit2;