From 1fbc09ca800d7ebda2dcc7fa2741e01cf0ff8cb3 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 8 Oct 2024 11:38:12 -0400 Subject: [PATCH 01/10] Update Pigeon and SK2 definition --- .../Classes/StoreKit2/sk2_pigeon.g.swift | 22 +- .../darwin/Classes/messages.g.h | 10 +- .../darwin/Classes/messages.g.m | 450 ++++++++------ .../lib/src/messages.g.dart | 586 +++++++++--------- .../lib/src/sk2_pigeon.g.dart | 12 +- .../sk2_product_wrapper.dart | 4 - .../pigeons/sk2_pigeon.dart | 4 +- .../in_app_purchase_storekit/pubspec.yaml | 2 +- .../test/fakes/fake_storekit_platform.dart | 8 +- ...rchase_storekit_platform_addtion_test.dart | 2 +- ...n_app_purchase_storekit_platform_test.dart | 2 +- .../test/sk2_test_api.g.dart | 12 +- .../sk_methodchannel_apis_test.dart | 4 +- .../sk_payment_queue_delegate_api_test.dart | 2 +- .../test/test_api.g.dart | 273 ++++---- 15 files changed, 772 insertions(+), 621 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/StoreKit2/sk2_pigeon.g.swift b/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/StoreKit2/sk2_pigeon.g.swift index 119fb288f36..09c71cf0289 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/StoreKit2/sk2_pigeon.g.swift +++ b/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/StoreKit2/sk2_pigeon.g.swift @@ -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.0.0), do not edit directly. +// Autogenerated from Pigeon (v22.4.2), do not edit directly. // See also: https://pub.dev/packages/pigeon import Foundation @@ -111,8 +111,7 @@ struct SK2SubscriptionOfferMessage { let price = pigeonVar_list[1] as! Double let type = pigeonVar_list[2] as! SK2SubscriptionOfferTypeMessage let period = pigeonVar_list[3] as! SK2SubscriptionPeriodMessage - let periodCount = - pigeonVar_list[4] is Int64 ? pigeonVar_list[4] as! Int64 : Int64(pigeonVar_list[4] as! Int32) + let periodCount = pigeonVar_list[4] as! Int64 let paymentMode = pigeonVar_list[5] as! SK2SubscriptionOfferPaymentModeMessage return SK2SubscriptionOfferMessage( @@ -145,8 +144,7 @@ struct SK2SubscriptionPeriodMessage { // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2SubscriptionPeriodMessage? { - let value = - pigeonVar_list[0] is Int64 ? pigeonVar_list[0] as! Int64 : Int64(pigeonVar_list[0] as! Int32) + let value = pigeonVar_list[0] as! Int64 let unit = pigeonVar_list[1] as! SK2SubscriptionPeriodUnitMessage return SK2SubscriptionPeriodMessage( @@ -165,9 +163,7 @@ struct SK2SubscriptionPeriodMessage { /// Generated class from Pigeon that represents data sent in messages. struct SK2SubscriptionInfoMessage { /// An array of all the promotional offers configured for this subscription. - /// This should be List but pigeon doesnt support - /// null-safe generics. https://github.com/flutter/flutter/issues/97848 - var promotionalOffers: [SK2SubscriptionOfferMessage?] + var promotionalOffers: [SK2SubscriptionOfferMessage] /// The group identifier for this subscription. var subscriptionGroupID: String /// The duration that this subscription lasts before auto-renewing. @@ -175,7 +171,7 @@ struct SK2SubscriptionInfoMessage { // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2SubscriptionInfoMessage? { - let promotionalOffers = pigeonVar_list[0] as! [SK2SubscriptionOfferMessage?] + let promotionalOffers = pigeonVar_list[0] as! [SK2SubscriptionOfferMessage] let subscriptionGroupID = pigeonVar_list[1] as! String let subscriptionPeriod = pigeonVar_list[2] as! SK2SubscriptionPeriodMessage @@ -279,25 +275,25 @@ private class sk2_pigeonPigeonCodecReader: FlutterStandardReader { override func readValue(ofType type: UInt8) -> Any? { switch type { case 129: - let enumResultAsInt: Int? = nilOrValue(self.readValue() as? Int) + let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) if let enumResultAsInt = enumResultAsInt { return SK2ProductTypeMessage(rawValue: enumResultAsInt) } return nil case 130: - let enumResultAsInt: Int? = nilOrValue(self.readValue() as? Int) + let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) if let enumResultAsInt = enumResultAsInt { return SK2SubscriptionOfferTypeMessage(rawValue: enumResultAsInt) } return nil case 131: - let enumResultAsInt: Int? = nilOrValue(self.readValue() as? Int) + let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) if let enumResultAsInt = enumResultAsInt { return SK2SubscriptionOfferPaymentModeMessage(rawValue: enumResultAsInt) } return nil case 132: - let enumResultAsInt: Int? = nilOrValue(self.readValue() as? Int) + let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) if let enumResultAsInt = enumResultAsInt { return SK2SubscriptionPeriodUnitMessage(rawValue: enumResultAsInt) } 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 7775d8d47ba..2ad1f03f7e9 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 (v16.0.4), do not edit directly. +// Autogenerated from Pigeon (v22.4.2), do not edit directly. // See also: https://pub.dev/packages/pigeon #import @@ -247,8 +247,8 @@ typedef NS_ENUM(NSUInteger, SKSubscriptionPeriodUnitMessage) { @property(nonatomic, assign) SKSubscriptionPeriodUnitMessage unit; @end -/// The codec used by InAppPurchaseAPI. -NSObject *InAppPurchaseAPIGetCodec(void); +/// The codec used by all APIs. +NSObject *nullGetMessagesCodec(void); @protocol InAppPurchaseAPI /// Returns if the current device is able to make payments @@ -283,4 +283,8 @@ NSObject *InAppPurchaseAPIGetCodec(void); extern void SetUpInAppPurchaseAPI(id binaryMessenger, NSObject *_Nullable api); +extern void SetUpInAppPurchaseAPIWithSuffix(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 50a358479fa..1e36142208a 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 (v16.0.5), do not edit directly. +// Autogenerated from Pigeon (v22.4.2), do not edit directly. // See also: https://pub.dev/packages/pigeon #import "messages.g.h" @@ -16,7 +16,7 @@ #error File requires ARC to be enabled. #endif -static NSArray *wrapResult(id result, FlutterError *error) { +static NSArray *wrapResult(id result, FlutterError *error) { if (error) { return @[ error.code ?: [NSNull null], error.message ?: [NSNull null], error.details ?: [NSNull null] @@ -25,7 +25,7 @@ return @[ result ?: [NSNull null] ]; } -static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) { +static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) { id result = array[key]; return (result == [NSNull null]) ? nil : result; } @@ -71,63 +71,63 @@ - (instancetype)initWithValue:(SKSubscriptionPeriodUnitMessage)value { @end @interface SKPaymentTransactionMessage () -+ (SKPaymentTransactionMessage *)fromList:(NSArray *)list; -+ (nullable SKPaymentTransactionMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; ++ (SKPaymentTransactionMessage *)fromList:(NSArray *)list; ++ (nullable SKPaymentTransactionMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface SKPaymentMessage () -+ (SKPaymentMessage *)fromList:(NSArray *)list; -+ (nullable SKPaymentMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; ++ (SKPaymentMessage *)fromList:(NSArray *)list; ++ (nullable SKPaymentMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface SKErrorMessage () -+ (SKErrorMessage *)fromList:(NSArray *)list; -+ (nullable SKErrorMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; ++ (SKErrorMessage *)fromList:(NSArray *)list; ++ (nullable SKErrorMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface SKPaymentDiscountMessage () -+ (SKPaymentDiscountMessage *)fromList:(NSArray *)list; -+ (nullable SKPaymentDiscountMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; ++ (SKPaymentDiscountMessage *)fromList:(NSArray *)list; ++ (nullable SKPaymentDiscountMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface SKStorefrontMessage () -+ (SKStorefrontMessage *)fromList:(NSArray *)list; -+ (nullable SKStorefrontMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; ++ (SKStorefrontMessage *)fromList:(NSArray *)list; ++ (nullable SKStorefrontMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface SKProductsResponseMessage () -+ (SKProductsResponseMessage *)fromList:(NSArray *)list; -+ (nullable SKProductsResponseMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; ++ (SKProductsResponseMessage *)fromList:(NSArray *)list; ++ (nullable SKProductsResponseMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface SKProductMessage () -+ (SKProductMessage *)fromList:(NSArray *)list; -+ (nullable SKProductMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; ++ (SKProductMessage *)fromList:(NSArray *)list; ++ (nullable SKProductMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface SKPriceLocaleMessage () -+ (SKPriceLocaleMessage *)fromList:(NSArray *)list; -+ (nullable SKPriceLocaleMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; ++ (SKPriceLocaleMessage *)fromList:(NSArray *)list; ++ (nullable SKPriceLocaleMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface SKProductDiscountMessage () -+ (SKProductDiscountMessage *)fromList:(NSArray *)list; -+ (nullable SKProductDiscountMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; ++ (SKProductDiscountMessage *)fromList:(NSArray *)list; ++ (nullable SKProductDiscountMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @interface SKProductSubscriptionPeriodMessage () -+ (SKProductSubscriptionPeriodMessage *)fromList:(NSArray *)list; -+ (nullable SKProductSubscriptionPeriodMessage *)nullableFromList:(NSArray *)list; -- (NSArray *)toList; ++ (SKProductSubscriptionPeriodMessage *)fromList:(NSArray *)list; ++ (nullable SKProductSubscriptionPeriodMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @implementation SKPaymentTransactionMessage @@ -146,28 +146,29 @@ + (instancetype)makeWithPayment:(SKPaymentMessage *)payment pigeonResult.error = error; return pigeonResult; } -+ (SKPaymentTransactionMessage *)fromList:(NSArray *)list { ++ (SKPaymentTransactionMessage *)fromList:(NSArray *)list { SKPaymentTransactionMessage *pigeonResult = [[SKPaymentTransactionMessage alloc] init]; - pigeonResult.payment = [SKPaymentMessage nullableFromList:(GetNullableObjectAtIndex(list, 0))]; - pigeonResult.transactionState = [GetNullableObjectAtIndex(list, 1) integerValue]; - pigeonResult.originalTransaction = - [SKPaymentTransactionMessage nullableFromList:(GetNullableObjectAtIndex(list, 2))]; + pigeonResult.payment = GetNullableObjectAtIndex(list, 0); + SKPaymentTransactionStateMessageBox *boxedSKPaymentTransactionStateMessage = + GetNullableObjectAtIndex(list, 1); + pigeonResult.transactionState = boxedSKPaymentTransactionStateMessage.value; + pigeonResult.originalTransaction = GetNullableObjectAtIndex(list, 2); pigeonResult.transactionTimeStamp = GetNullableObjectAtIndex(list, 3); pigeonResult.transactionIdentifier = GetNullableObjectAtIndex(list, 4); - pigeonResult.error = [SKErrorMessage nullableFromList:(GetNullableObjectAtIndex(list, 5))]; + pigeonResult.error = GetNullableObjectAtIndex(list, 5); return pigeonResult; } -+ (nullable SKPaymentTransactionMessage *)nullableFromList:(NSArray *)list { ++ (nullable SKPaymentTransactionMessage *)nullableFromList:(NSArray *)list { return (list) ? [SKPaymentTransactionMessage fromList:list] : nil; } -- (NSArray *)toList { +- (NSArray *)toList { return @[ - (self.payment ? [self.payment toList] : [NSNull null]), - @(self.transactionState), - (self.originalTransaction ? [self.originalTransaction toList] : [NSNull null]), + self.payment ?: [NSNull null], + [[SKPaymentTransactionStateMessageBox alloc] initWithValue:self.transactionState], + self.originalTransaction ?: [NSNull null], self.transactionTimeStamp ?: [NSNull null], self.transactionIdentifier ?: [NSNull null], - (self.error ? [self.error toList] : [NSNull null]), + self.error ?: [NSNull null], ]; } @end @@ -188,28 +189,27 @@ + (instancetype)makeWithProductIdentifier:(NSString *)productIdentifier pigeonResult.paymentDiscount = paymentDiscount; return pigeonResult; } -+ (SKPaymentMessage *)fromList:(NSArray *)list { ++ (SKPaymentMessage *)fromList:(NSArray *)list { SKPaymentMessage *pigeonResult = [[SKPaymentMessage alloc] init]; pigeonResult.productIdentifier = GetNullableObjectAtIndex(list, 0); pigeonResult.applicationUsername = GetNullableObjectAtIndex(list, 1); pigeonResult.requestData = GetNullableObjectAtIndex(list, 2); pigeonResult.quantity = [GetNullableObjectAtIndex(list, 3) integerValue]; pigeonResult.simulatesAskToBuyInSandbox = [GetNullableObjectAtIndex(list, 4) boolValue]; - pigeonResult.paymentDiscount = - [SKPaymentDiscountMessage nullableFromList:(GetNullableObjectAtIndex(list, 5))]; + pigeonResult.paymentDiscount = GetNullableObjectAtIndex(list, 5); return pigeonResult; } -+ (nullable SKPaymentMessage *)nullableFromList:(NSArray *)list { ++ (nullable SKPaymentMessage *)nullableFromList:(NSArray *)list { return (list) ? [SKPaymentMessage fromList:list] : nil; } -- (NSArray *)toList { +- (NSArray *)toList { return @[ self.productIdentifier ?: [NSNull null], self.applicationUsername ?: [NSNull null], self.requestData ?: [NSNull null], @(self.quantity), @(self.simulatesAskToBuyInSandbox), - (self.paymentDiscount ? [self.paymentDiscount toList] : [NSNull null]), + self.paymentDiscount ?: [NSNull null], ]; } @end @@ -224,17 +224,17 @@ + (instancetype)makeWithCode:(NSInteger)code pigeonResult.userInfo = userInfo; return pigeonResult; } -+ (SKErrorMessage *)fromList:(NSArray *)list { ++ (SKErrorMessage *)fromList:(NSArray *)list { SKErrorMessage *pigeonResult = [[SKErrorMessage alloc] init]; pigeonResult.code = [GetNullableObjectAtIndex(list, 0) integerValue]; pigeonResult.domain = GetNullableObjectAtIndex(list, 1); pigeonResult.userInfo = GetNullableObjectAtIndex(list, 2); return pigeonResult; } -+ (nullable SKErrorMessage *)nullableFromList:(NSArray *)list { ++ (nullable SKErrorMessage *)nullableFromList:(NSArray *)list { return (list) ? [SKErrorMessage fromList:list] : nil; } -- (NSArray *)toList { +- (NSArray *)toList { return @[ @(self.code), self.domain ?: [NSNull null], @@ -257,7 +257,7 @@ + (instancetype)makeWithIdentifier:(NSString *)identifier pigeonResult.timestamp = timestamp; return pigeonResult; } -+ (SKPaymentDiscountMessage *)fromList:(NSArray *)list { ++ (SKPaymentDiscountMessage *)fromList:(NSArray *)list { SKPaymentDiscountMessage *pigeonResult = [[SKPaymentDiscountMessage alloc] init]; pigeonResult.identifier = GetNullableObjectAtIndex(list, 0); pigeonResult.keyIdentifier = GetNullableObjectAtIndex(list, 1); @@ -266,10 +266,10 @@ + (SKPaymentDiscountMessage *)fromList:(NSArray *)list { pigeonResult.timestamp = [GetNullableObjectAtIndex(list, 4) integerValue]; return pigeonResult; } -+ (nullable SKPaymentDiscountMessage *)nullableFromList:(NSArray *)list { ++ (nullable SKPaymentDiscountMessage *)nullableFromList:(NSArray *)list { return (list) ? [SKPaymentDiscountMessage fromList:list] : nil; } -- (NSArray *)toList { +- (NSArray *)toList { return @[ self.identifier ?: [NSNull null], self.keyIdentifier ?: [NSNull null], @@ -287,16 +287,16 @@ + (instancetype)makeWithCountryCode:(NSString *)countryCode identifier:(NSString pigeonResult.identifier = identifier; return pigeonResult; } -+ (SKStorefrontMessage *)fromList:(NSArray *)list { ++ (SKStorefrontMessage *)fromList:(NSArray *)list { SKStorefrontMessage *pigeonResult = [[SKStorefrontMessage alloc] init]; pigeonResult.countryCode = GetNullableObjectAtIndex(list, 0); pigeonResult.identifier = GetNullableObjectAtIndex(list, 1); return pigeonResult; } -+ (nullable SKStorefrontMessage *)nullableFromList:(NSArray *)list { ++ (nullable SKStorefrontMessage *)nullableFromList:(NSArray *)list { return (list) ? [SKStorefrontMessage fromList:list] : nil; } -- (NSArray *)toList { +- (NSArray *)toList { return @[ self.countryCode ?: [NSNull null], self.identifier ?: [NSNull null], @@ -312,16 +312,16 @@ + (instancetype)makeWithProducts:(nullable NSArray *)product pigeonResult.invalidProductIdentifiers = invalidProductIdentifiers; return pigeonResult; } -+ (SKProductsResponseMessage *)fromList:(NSArray *)list { ++ (SKProductsResponseMessage *)fromList:(NSArray *)list { SKProductsResponseMessage *pigeonResult = [[SKProductsResponseMessage alloc] init]; pigeonResult.products = GetNullableObjectAtIndex(list, 0); pigeonResult.invalidProductIdentifiers = GetNullableObjectAtIndex(list, 1); return pigeonResult; } -+ (nullable SKProductsResponseMessage *)nullableFromList:(NSArray *)list { ++ (nullable SKProductsResponseMessage *)nullableFromList:(NSArray *)list { return (list) ? [SKProductsResponseMessage fromList:list] : nil; } -- (NSArray *)toList { +- (NSArray *)toList { return @[ self.products ?: [NSNull null], self.invalidProductIdentifiers ?: [NSNull null], @@ -352,35 +352,32 @@ @implementation SKProductMessage pigeonResult.discounts = discounts; return pigeonResult; } -+ (SKProductMessage *)fromList:(NSArray *)list { ++ (SKProductMessage *)fromList:(NSArray *)list { SKProductMessage *pigeonResult = [[SKProductMessage alloc] init]; pigeonResult.productIdentifier = GetNullableObjectAtIndex(list, 0); pigeonResult.localizedTitle = GetNullableObjectAtIndex(list, 1); pigeonResult.localizedDescription = GetNullableObjectAtIndex(list, 2); - pigeonResult.priceLocale = - [SKPriceLocaleMessage nullableFromList:(GetNullableObjectAtIndex(list, 3))]; + pigeonResult.priceLocale = GetNullableObjectAtIndex(list, 3); pigeonResult.subscriptionGroupIdentifier = GetNullableObjectAtIndex(list, 4); pigeonResult.price = GetNullableObjectAtIndex(list, 5); - pigeonResult.subscriptionPeriod = - [SKProductSubscriptionPeriodMessage nullableFromList:(GetNullableObjectAtIndex(list, 6))]; - pigeonResult.introductoryPrice = - [SKProductDiscountMessage nullableFromList:(GetNullableObjectAtIndex(list, 7))]; + pigeonResult.subscriptionPeriod = GetNullableObjectAtIndex(list, 6); + pigeonResult.introductoryPrice = GetNullableObjectAtIndex(list, 7); pigeonResult.discounts = GetNullableObjectAtIndex(list, 8); return pigeonResult; } -+ (nullable SKProductMessage *)nullableFromList:(NSArray *)list { ++ (nullable SKProductMessage *)nullableFromList:(NSArray *)list { return (list) ? [SKProductMessage fromList:list] : nil; } -- (NSArray *)toList { +- (NSArray *)toList { return @[ self.productIdentifier ?: [NSNull null], self.localizedTitle ?: [NSNull null], self.localizedDescription ?: [NSNull null], - (self.priceLocale ? [self.priceLocale toList] : [NSNull null]), + self.priceLocale ?: [NSNull null], self.subscriptionGroupIdentifier ?: [NSNull null], self.price ?: [NSNull null], - (self.subscriptionPeriod ? [self.subscriptionPeriod toList] : [NSNull null]), - (self.introductoryPrice ? [self.introductoryPrice toList] : [NSNull null]), + self.subscriptionPeriod ?: [NSNull null], + self.introductoryPrice ?: [NSNull null], self.discounts ?: [NSNull null], ]; } @@ -396,17 +393,17 @@ + (instancetype)makeWithCurrencySymbol:(NSString *)currencySymbol pigeonResult.countryCode = countryCode; return pigeonResult; } -+ (SKPriceLocaleMessage *)fromList:(NSArray *)list { ++ (SKPriceLocaleMessage *)fromList:(NSArray *)list { SKPriceLocaleMessage *pigeonResult = [[SKPriceLocaleMessage alloc] init]; pigeonResult.currencySymbol = GetNullableObjectAtIndex(list, 0); pigeonResult.currencyCode = GetNullableObjectAtIndex(list, 1); pigeonResult.countryCode = GetNullableObjectAtIndex(list, 2); return pigeonResult; } -+ (nullable SKPriceLocaleMessage *)nullableFromList:(NSArray *)list { ++ (nullable SKPriceLocaleMessage *)nullableFromList:(NSArray *)list { return (list) ? [SKPriceLocaleMessage fromList:list] : nil; } -- (NSArray *)toList { +- (NSArray *)toList { return @[ self.currencySymbol ?: [NSNull null], self.currencyCode ?: [NSNull null], @@ -433,31 +430,33 @@ + (instancetype)makeWithPrice:(NSString *)price pigeonResult.type = type; return pigeonResult; } -+ (SKProductDiscountMessage *)fromList:(NSArray *)list { ++ (SKProductDiscountMessage *)fromList:(NSArray *)list { SKProductDiscountMessage *pigeonResult = [[SKProductDiscountMessage alloc] init]; pigeonResult.price = GetNullableObjectAtIndex(list, 0); - pigeonResult.priceLocale = - [SKPriceLocaleMessage nullableFromList:(GetNullableObjectAtIndex(list, 1))]; + pigeonResult.priceLocale = GetNullableObjectAtIndex(list, 1); pigeonResult.numberOfPeriods = [GetNullableObjectAtIndex(list, 2) integerValue]; - pigeonResult.paymentMode = [GetNullableObjectAtIndex(list, 3) integerValue]; - pigeonResult.subscriptionPeriod = - [SKProductSubscriptionPeriodMessage nullableFromList:(GetNullableObjectAtIndex(list, 4))]; + SKProductDiscountPaymentModeMessageBox *boxedSKProductDiscountPaymentModeMessage = + GetNullableObjectAtIndex(list, 3); + pigeonResult.paymentMode = boxedSKProductDiscountPaymentModeMessage.value; + pigeonResult.subscriptionPeriod = GetNullableObjectAtIndex(list, 4); pigeonResult.identifier = GetNullableObjectAtIndex(list, 5); - pigeonResult.type = [GetNullableObjectAtIndex(list, 6) integerValue]; + SKProductDiscountTypeMessageBox *boxedSKProductDiscountTypeMessage = + GetNullableObjectAtIndex(list, 6); + pigeonResult.type = boxedSKProductDiscountTypeMessage.value; return pigeonResult; } -+ (nullable SKProductDiscountMessage *)nullableFromList:(NSArray *)list { ++ (nullable SKProductDiscountMessage *)nullableFromList:(NSArray *)list { return (list) ? [SKProductDiscountMessage fromList:list] : nil; } -- (NSArray *)toList { +- (NSArray *)toList { return @[ self.price ?: [NSNull null], - (self.priceLocale ? [self.priceLocale toList] : [NSNull null]), + self.priceLocale ?: [NSNull null], @(self.numberOfPeriods), - @(self.paymentMode), - (self.subscriptionPeriod ? [self.subscriptionPeriod toList] : [NSNull null]), + [[SKProductDiscountPaymentModeMessageBox alloc] initWithValue:self.paymentMode], + self.subscriptionPeriod ?: [NSNull null], self.identifier ?: [NSNull null], - @(self.type), + [[SKProductDiscountTypeMessageBox alloc] initWithValue:self.type], ]; } @end @@ -471,126 +470,178 @@ + (instancetype)makeWithNumberOfUnits:(NSInteger)numberOfUnits pigeonResult.unit = unit; return pigeonResult; } -+ (SKProductSubscriptionPeriodMessage *)fromList:(NSArray *)list { ++ (SKProductSubscriptionPeriodMessage *)fromList:(NSArray *)list { SKProductSubscriptionPeriodMessage *pigeonResult = [[SKProductSubscriptionPeriodMessage alloc] init]; pigeonResult.numberOfUnits = [GetNullableObjectAtIndex(list, 0) integerValue]; - pigeonResult.unit = [GetNullableObjectAtIndex(list, 1) integerValue]; + SKSubscriptionPeriodUnitMessageBox *boxedSKSubscriptionPeriodUnitMessage = + GetNullableObjectAtIndex(list, 1); + pigeonResult.unit = boxedSKSubscriptionPeriodUnitMessage.value; return pigeonResult; } -+ (nullable SKProductSubscriptionPeriodMessage *)nullableFromList:(NSArray *)list { ++ (nullable SKProductSubscriptionPeriodMessage *)nullableFromList:(NSArray *)list { return (list) ? [SKProductSubscriptionPeriodMessage fromList:list] : nil; } -- (NSArray *)toList { +- (NSArray *)toList { return @[ @(self.numberOfUnits), - @(self.unit), + [[SKSubscriptionPeriodUnitMessageBox alloc] initWithValue:self.unit], ]; } @end -@interface InAppPurchaseAPICodecReader : FlutterStandardReader +@interface nullMessagesPigeonCodecReader : FlutterStandardReader @end -@implementation InAppPurchaseAPICodecReader +@implementation nullMessagesPigeonCodecReader - (nullable id)readValueOfType:(UInt8)type { switch (type) { - case 128: - return [SKErrorMessage fromList:[self readValue]]; - case 129: - return [SKPaymentDiscountMessage fromList:[self readValue]]; - case 130: - return [SKPaymentMessage fromList:[self readValue]]; - case 131: - return [SKPaymentTransactionMessage fromList:[self readValue]]; - case 132: - return [SKPriceLocaleMessage fromList:[self readValue]]; + case 129: { + NSNumber *enumAsNumber = [self readValue]; + return enumAsNumber == nil ? nil + : [[SKPaymentTransactionStateMessageBox alloc] + initWithValue:[enumAsNumber integerValue]]; + } + case 130: { + NSNumber *enumAsNumber = [self readValue]; + return enumAsNumber == nil ? nil + : [[SKProductDiscountTypeMessageBox alloc] + initWithValue:[enumAsNumber integerValue]]; + } + case 131: { + NSNumber *enumAsNumber = [self readValue]; + return enumAsNumber == nil ? nil + : [[SKProductDiscountPaymentModeMessageBox alloc] + initWithValue:[enumAsNumber integerValue]]; + } + case 132: { + NSNumber *enumAsNumber = [self readValue]; + return enumAsNumber == nil ? nil + : [[SKSubscriptionPeriodUnitMessageBox alloc] + initWithValue:[enumAsNumber integerValue]]; + } case 133: - return [SKProductDiscountMessage fromList:[self readValue]]; + return [SKPaymentTransactionMessage fromList:[self readValue]]; case 134: - return [SKProductMessage fromList:[self readValue]]; + return [SKPaymentMessage fromList:[self readValue]]; case 135: - return [SKProductSubscriptionPeriodMessage fromList:[self readValue]]; + return [SKErrorMessage fromList:[self readValue]]; case 136: - return [SKProductsResponseMessage fromList:[self readValue]]; + return [SKPaymentDiscountMessage fromList:[self readValue]]; case 137: return [SKStorefrontMessage fromList:[self readValue]]; + case 138: + return [SKProductsResponseMessage fromList:[self readValue]]; + case 139: + return [SKProductMessage fromList:[self readValue]]; + case 140: + return [SKPriceLocaleMessage fromList:[self readValue]]; + case 141: + return [SKProductDiscountMessage fromList:[self readValue]]; + case 142: + return [SKProductSubscriptionPeriodMessage fromList:[self readValue]]; default: return [super readValueOfType:type]; } } @end -@interface InAppPurchaseAPICodecWriter : FlutterStandardWriter +@interface nullMessagesPigeonCodecWriter : FlutterStandardWriter @end -@implementation InAppPurchaseAPICodecWriter +@implementation nullMessagesPigeonCodecWriter - (void)writeValue:(id)value { - if ([value isKindOfClass:[SKErrorMessage class]]) { - [self writeByte:128]; - [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[SKPaymentDiscountMessage class]]) { + if ([value isKindOfClass:[SKPaymentTransactionStateMessageBox class]]) { + SKPaymentTransactionStateMessageBox *box = (SKPaymentTransactionStateMessageBox *)value; [self writeByte:129]; - [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[SKPaymentMessage class]]) { + [self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])]; + } else if ([value isKindOfClass:[SKProductDiscountTypeMessageBox class]]) { + SKProductDiscountTypeMessageBox *box = (SKProductDiscountTypeMessageBox *)value; [self writeByte:130]; - [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[SKPaymentTransactionMessage class]]) { + [self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])]; + } else if ([value isKindOfClass:[SKProductDiscountPaymentModeMessageBox class]]) { + SKProductDiscountPaymentModeMessageBox *box = (SKProductDiscountPaymentModeMessageBox *)value; [self writeByte:131]; - [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[SKPriceLocaleMessage class]]) { + [self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])]; + } else if ([value isKindOfClass:[SKSubscriptionPeriodUnitMessageBox class]]) { + SKSubscriptionPeriodUnitMessageBox *box = (SKSubscriptionPeriodUnitMessageBox *)value; [self writeByte:132]; - [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[SKProductDiscountMessage class]]) { + [self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])]; + } else if ([value isKindOfClass:[SKPaymentTransactionMessage class]]) { [self writeByte:133]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[SKProductMessage class]]) { + } else if ([value isKindOfClass:[SKPaymentMessage class]]) { [self writeByte:134]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[SKProductSubscriptionPeriodMessage class]]) { + } else if ([value isKindOfClass:[SKErrorMessage class]]) { [self writeByte:135]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[SKProductsResponseMessage class]]) { + } else if ([value isKindOfClass:[SKPaymentDiscountMessage class]]) { [self writeByte:136]; [self writeValue:[value toList]]; } else if ([value isKindOfClass:[SKStorefrontMessage class]]) { [self writeByte:137]; [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[SKProductsResponseMessage class]]) { + [self writeByte:138]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[SKProductMessage class]]) { + [self writeByte:139]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[SKPriceLocaleMessage class]]) { + [self writeByte:140]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[SKProductDiscountMessage class]]) { + [self writeByte:141]; + [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[SKProductSubscriptionPeriodMessage class]]) { + [self writeByte:142]; + [self writeValue:[value toList]]; } else { [super writeValue:value]; } } @end -@interface InAppPurchaseAPICodecReaderWriter : FlutterStandardReaderWriter +@interface nullMessagesPigeonCodecReaderWriter : FlutterStandardReaderWriter @end -@implementation InAppPurchaseAPICodecReaderWriter +@implementation nullMessagesPigeonCodecReaderWriter - (FlutterStandardWriter *)writerWithData:(NSMutableData *)data { - return [[InAppPurchaseAPICodecWriter alloc] initWithData:data]; + return [[nullMessagesPigeonCodecWriter alloc] initWithData:data]; } - (FlutterStandardReader *)readerWithData:(NSData *)data { - return [[InAppPurchaseAPICodecReader alloc] initWithData:data]; + return [[nullMessagesPigeonCodecReader alloc] initWithData:data]; } @end -NSObject *InAppPurchaseAPIGetCodec(void) { +NSObject *nullGetMessagesCodec(void) { static FlutterStandardMessageCodec *sSharedObject = nil; static dispatch_once_t sPred = 0; dispatch_once(&sPred, ^{ - InAppPurchaseAPICodecReaderWriter *readerWriter = - [[InAppPurchaseAPICodecReaderWriter alloc] init]; + nullMessagesPigeonCodecReaderWriter *readerWriter = + [[nullMessagesPigeonCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } - void SetUpInAppPurchaseAPI(id binaryMessenger, NSObject *api) { + SetUpInAppPurchaseAPIWithSuffix(binaryMessenger, api, @""); +} + +void SetUpInAppPurchaseAPIWithSuffix(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: - @"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.canMakePayments" + initWithName:[NSString stringWithFormat:@"%@%@", + @"dev.flutter.pigeon.in_app_purchase_storekit." + @"InAppPurchaseAPI.canMakePayments", + messageChannelSuffix] binaryMessenger:binaryMessenger - codec:InAppPurchaseAPIGetCodec()]; + codec:nullGetMessagesCodec()]; if (api) { NSCAssert( [api respondsToSelector:@selector(canMakePaymentsWithError:)], @@ -607,9 +658,12 @@ void SetUpInAppPurchaseAPI(id binaryMessenger, } { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.transactions" + initWithName:[NSString stringWithFormat:@"%@%@", + @"dev.flutter.pigeon.in_app_purchase_storekit." + @"InAppPurchaseAPI.transactions", + messageChannelSuffix] binaryMessenger:binaryMessenger - codec:InAppPurchaseAPIGetCodec()]; + codec:nullGetMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(transactionsWithError:)], @"InAppPurchaseAPI api (%@) doesn't respond to @selector(transactionsWithError:)", @@ -625,9 +679,12 @@ void SetUpInAppPurchaseAPI(id binaryMessenger, } { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.storefront" + initWithName:[NSString stringWithFormat:@"%@%@", + @"dev.flutter.pigeon.in_app_purchase_storekit." + @"InAppPurchaseAPI.storefront", + messageChannelSuffix] binaryMessenger:binaryMessenger - codec:InAppPurchaseAPIGetCodec()]; + codec:nullGetMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(storefrontWithError:)], @"InAppPurchaseAPI api (%@) doesn't respond to @selector(storefrontWithError:)", @@ -643,16 +700,19 @@ void SetUpInAppPurchaseAPI(id binaryMessenger, } { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.addPayment" + initWithName:[NSString stringWithFormat:@"%@%@", + @"dev.flutter.pigeon.in_app_purchase_storekit." + @"InAppPurchaseAPI.addPayment", + messageChannelSuffix] binaryMessenger:binaryMessenger - codec:InAppPurchaseAPIGetCodec()]; + codec:nullGetMessagesCodec()]; if (api) { NSCAssert( [api respondsToSelector:@selector(addPaymentPaymentMap:error:)], @"InAppPurchaseAPI api (%@) doesn't respond to @selector(addPaymentPaymentMap:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { - NSArray *args = message; + NSArray *args = message; NSDictionary *arg_paymentMap = GetNullableObjectAtIndex(args, 0); FlutterError *error; [api addPaymentPaymentMap:arg_paymentMap error:&error]; @@ -664,10 +724,12 @@ void SetUpInAppPurchaseAPI(id binaryMessenger, } { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName: - @"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startProductRequest" + initWithName:[NSString stringWithFormat:@"%@%@", + @"dev.flutter.pigeon.in_app_purchase_storekit." + @"InAppPurchaseAPI.startProductRequest", + messageChannelSuffix] binaryMessenger:binaryMessenger - codec:InAppPurchaseAPIGetCodec()]; + codec:nullGetMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(startProductRequestProductIdentifiers: completion:)], @@ -675,7 +737,7 @@ void SetUpInAppPurchaseAPI(id binaryMessenger, @"@selector(startProductRequestProductIdentifiers:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { - NSArray *args = message; + NSArray *args = message; NSArray *arg_productIdentifiers = GetNullableObjectAtIndex(args, 0); [api startProductRequestProductIdentifiers:arg_productIdentifiers completion:^(SKProductsResponseMessage *_Nullable output, @@ -689,17 +751,19 @@ void SetUpInAppPurchaseAPI(id binaryMessenger, } { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName: - @"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.finishTransaction" + initWithName:[NSString stringWithFormat:@"%@%@", + @"dev.flutter.pigeon.in_app_purchase_storekit." + @"InAppPurchaseAPI.finishTransaction", + messageChannelSuffix] binaryMessenger:binaryMessenger - codec:InAppPurchaseAPIGetCodec()]; + codec:nullGetMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(finishTransactionFinishMap:error:)], @"InAppPurchaseAPI api (%@) doesn't respond to " @"@selector(finishTransactionFinishMap:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { - NSArray *args = message; + NSArray *args = message; NSDictionary *arg_finishMap = GetNullableObjectAtIndex(args, 0); FlutterError *error; [api finishTransactionFinishMap:arg_finishMap error:&error]; @@ -711,17 +775,19 @@ void SetUpInAppPurchaseAPI(id binaryMessenger, } { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName: - @"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.restoreTransactions" + initWithName:[NSString stringWithFormat:@"%@%@", + @"dev.flutter.pigeon.in_app_purchase_storekit." + @"InAppPurchaseAPI.restoreTransactions", + messageChannelSuffix] binaryMessenger:binaryMessenger - codec:InAppPurchaseAPIGetCodec()]; + codec:nullGetMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(restoreTransactionsApplicationUserName:error:)], @"InAppPurchaseAPI api (%@) doesn't respond to " @"@selector(restoreTransactionsApplicationUserName:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { - NSArray *args = message; + NSArray *args = message; NSString *arg_applicationUserName = GetNullableObjectAtIndex(args, 0); FlutterError *error; [api restoreTransactionsApplicationUserName:arg_applicationUserName error:&error]; @@ -733,10 +799,12 @@ void SetUpInAppPurchaseAPI(id binaryMessenger, } { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI." - @"presentCodeRedemptionSheet" + initWithName:[NSString stringWithFormat:@"%@%@", + @"dev.flutter.pigeon.in_app_purchase_storekit." + @"InAppPurchaseAPI.presentCodeRedemptionSheet", + messageChannelSuffix] binaryMessenger:binaryMessenger - codec:InAppPurchaseAPIGetCodec()]; + codec:nullGetMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(presentCodeRedemptionSheetWithError:)], @"InAppPurchaseAPI api (%@) doesn't respond to " @@ -753,10 +821,12 @@ void SetUpInAppPurchaseAPI(id binaryMessenger, } { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName: - @"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.retrieveReceiptData" + initWithName:[NSString stringWithFormat:@"%@%@", + @"dev.flutter.pigeon.in_app_purchase_storekit." + @"InAppPurchaseAPI.retrieveReceiptData", + messageChannelSuffix] binaryMessenger:binaryMessenger - codec:InAppPurchaseAPIGetCodec()]; + codec:nullGetMessagesCodec()]; if (api) { NSCAssert( [api respondsToSelector:@selector(retrieveReceiptDataWithError:)], @@ -773,17 +843,19 @@ void SetUpInAppPurchaseAPI(id binaryMessenger, } { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName: - @"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.refreshReceipt" + initWithName:[NSString stringWithFormat:@"%@%@", + @"dev.flutter.pigeon.in_app_purchase_storekit." + @"InAppPurchaseAPI.refreshReceipt", + messageChannelSuffix] binaryMessenger:binaryMessenger - codec:InAppPurchaseAPIGetCodec()]; + codec:nullGetMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(refreshReceiptReceiptProperties:completion:)], @"InAppPurchaseAPI api (%@) doesn't respond to " @"@selector(refreshReceiptReceiptProperties:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { - NSArray *args = message; + NSArray *args = message; NSDictionary *arg_receiptProperties = GetNullableObjectAtIndex(args, 0); [api refreshReceiptReceiptProperties:arg_receiptProperties completion:^(FlutterError *_Nullable error) { @@ -796,10 +868,12 @@ void SetUpInAppPurchaseAPI(id binaryMessenger, } { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI." - @"startObservingPaymentQueue" + initWithName:[NSString stringWithFormat:@"%@%@", + @"dev.flutter.pigeon.in_app_purchase_storekit." + @"InAppPurchaseAPI.startObservingPaymentQueue", + messageChannelSuffix] binaryMessenger:binaryMessenger - codec:InAppPurchaseAPIGetCodec()]; + codec:nullGetMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(startObservingPaymentQueueWithError:)], @"InAppPurchaseAPI api (%@) doesn't respond to " @@ -816,10 +890,12 @@ void SetUpInAppPurchaseAPI(id binaryMessenger, } { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI." - @"stopObservingPaymentQueue" + initWithName:[NSString stringWithFormat:@"%@%@", + @"dev.flutter.pigeon.in_app_purchase_storekit." + @"InAppPurchaseAPI.stopObservingPaymentQueue", + messageChannelSuffix] binaryMessenger:binaryMessenger - codec:InAppPurchaseAPIGetCodec()]; + codec:nullGetMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(stopObservingPaymentQueueWithError:)], @"InAppPurchaseAPI api (%@) doesn't respond to " @@ -836,10 +912,12 @@ void SetUpInAppPurchaseAPI(id binaryMessenger, } { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI." - @"registerPaymentQueueDelegate" + initWithName:[NSString stringWithFormat:@"%@%@", + @"dev.flutter.pigeon.in_app_purchase_storekit." + @"InAppPurchaseAPI.registerPaymentQueueDelegate", + messageChannelSuffix] binaryMessenger:binaryMessenger - codec:InAppPurchaseAPIGetCodec()]; + codec:nullGetMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(registerPaymentQueueDelegateWithError:)], @"InAppPurchaseAPI api (%@) doesn't respond to " @@ -856,10 +934,12 @@ void SetUpInAppPurchaseAPI(id binaryMessenger, } { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI." - @"removePaymentQueueDelegate" + initWithName:[NSString stringWithFormat:@"%@%@", + @"dev.flutter.pigeon.in_app_purchase_storekit." + @"InAppPurchaseAPI.removePaymentQueueDelegate", + messageChannelSuffix] binaryMessenger:binaryMessenger - codec:InAppPurchaseAPIGetCodec()]; + codec:nullGetMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(removePaymentQueueDelegateWithError:)], @"InAppPurchaseAPI api (%@) doesn't respond to " @@ -876,10 +956,12 @@ void SetUpInAppPurchaseAPI(id binaryMessenger, } { FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc] - initWithName:@"dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI." - @"showPriceConsentIfNeeded" + initWithName:[NSString stringWithFormat:@"%@%@", + @"dev.flutter.pigeon.in_app_purchase_storekit." + @"InAppPurchaseAPI.showPriceConsentIfNeeded", + messageChannelSuffix] binaryMessenger:binaryMessenger - codec:InAppPurchaseAPIGetCodec()]; + codec:nullGetMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(showPriceConsentIfNeededWithError:)], @"InAppPurchaseAPI api (%@) doesn't respond to " 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 a53187575e1..bd41a66cdd3 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 (v16.0.5), do not edit directly. +// Autogenerated from Pigeon (v22.4.2), 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 @@ -119,29 +119,24 @@ class SKPaymentTransactionMessage { Object encode() { return [ - payment.encode(), - transactionState.index, - originalTransaction?.encode(), + payment, + transactionState, + originalTransaction, transactionTimeStamp, transactionIdentifier, - error?.encode(), + error, ]; } static SKPaymentTransactionMessage decode(Object result) { result as List; return SKPaymentTransactionMessage( - payment: SKPaymentMessage.decode(result[0]! as List), - transactionState: - SKPaymentTransactionStateMessage.values[result[1]! as int], - originalTransaction: result[2] != null - ? SKPaymentTransactionMessage.decode(result[2]! as List) - : null, + payment: result[0]! as SKPaymentMessage, + transactionState: result[1]! as SKPaymentTransactionStateMessage, + originalTransaction: result[2] as SKPaymentTransactionMessage?, transactionTimeStamp: result[3] as double?, transactionIdentifier: result[4] as String?, - error: result[5] != null - ? SKErrorMessage.decode(result[5]! as List) - : null, + error: result[5] as SKErrorMessage?, ); } } @@ -175,7 +170,7 @@ class SKPaymentMessage { requestData, quantity, simulatesAskToBuyInSandbox, - paymentDiscount?.encode(), + paymentDiscount, ]; } @@ -187,9 +182,7 @@ class SKPaymentMessage { requestData: result[2] as String?, quantity: result[3]! as int, simulatesAskToBuyInSandbox: result[4]! as bool, - paymentDiscount: result[5] != null - ? SKPaymentDiscountMessage.decode(result[5]! as List) - : null, + paymentDiscount: result[5] as SKPaymentDiscountMessage?, ); } } @@ -354,11 +347,11 @@ class SKProductMessage { productIdentifier, localizedTitle, localizedDescription, - priceLocale.encode(), + priceLocale, subscriptionGroupIdentifier, price, - subscriptionPeriod?.encode(), - introductoryPrice?.encode(), + subscriptionPeriod, + introductoryPrice, discounts, ]; } @@ -369,16 +362,11 @@ class SKProductMessage { productIdentifier: result[0]! as String, localizedTitle: result[1]! as String, localizedDescription: result[2] as String?, - priceLocale: SKPriceLocaleMessage.decode(result[3]! as List), + priceLocale: result[3]! as SKPriceLocaleMessage, subscriptionGroupIdentifier: result[4] as String?, price: result[5]! as String, - subscriptionPeriod: result[6] != null - ? SKProductSubscriptionPeriodMessage.decode( - result[6]! as List) - : null, - introductoryPrice: result[7] != null - ? SKProductDiscountMessage.decode(result[7]! as List) - : null, + subscriptionPeriod: result[6] as SKProductSubscriptionPeriodMessage?, + introductoryPrice: result[7] as SKProductDiscountMessage?, discounts: (result[8] as List?)?.cast(), ); @@ -447,12 +435,12 @@ class SKProductDiscountMessage { Object encode() { return [ price, - priceLocale.encode(), + priceLocale, numberOfPeriods, - paymentMode.index, - subscriptionPeriod.encode(), + paymentMode, + subscriptionPeriod, identifier, - type.index, + type, ]; } @@ -460,14 +448,12 @@ class SKProductDiscountMessage { result as List; return SKProductDiscountMessage( price: result[0]! as String, - priceLocale: SKPriceLocaleMessage.decode(result[1]! as List), + priceLocale: result[1]! as SKPriceLocaleMessage, numberOfPeriods: result[2]! as int, - paymentMode: - SKProductDiscountPaymentModeMessage.values[result[3]! as int], - subscriptionPeriod: SKProductSubscriptionPeriodMessage.decode( - result[4]! as List), + paymentMode: result[3]! as SKProductDiscountPaymentModeMessage, + subscriptionPeriod: result[4]! as SKProductSubscriptionPeriodMessage, identifier: result[5] as String?, - type: SKProductDiscountTypeMessage.values[result[6]! as int], + type: result[6]! as SKProductDiscountTypeMessage, ); } } @@ -485,7 +471,7 @@ class SKProductSubscriptionPeriodMessage { Object encode() { return [ numberOfUnits, - unit.index, + unit, ]; } @@ -493,45 +479,60 @@ class SKProductSubscriptionPeriodMessage { result as List; return SKProductSubscriptionPeriodMessage( numberOfUnits: result[0]! as int, - unit: SKSubscriptionPeriodUnitMessage.values[result[1]! as int], + unit: result[1]! as SKSubscriptionPeriodUnitMessage, ); } } -class _InAppPurchaseAPICodec extends StandardMessageCodec { - const _InAppPurchaseAPICodec(); +class _PigeonCodec extends StandardMessageCodec { + const _PigeonCodec(); @override void writeValue(WriteBuffer buffer, Object? value) { - if (value is SKErrorMessage) { - buffer.putUint8(128); - writeValue(buffer, value.encode()); - } else if (value is SKPaymentDiscountMessage) { + if (value is int) { + buffer.putUint8(4); + buffer.putInt64(value); + } else if (value is SKPaymentTransactionStateMessage) { buffer.putUint8(129); - writeValue(buffer, value.encode()); - } else if (value is SKPaymentMessage) { + writeValue(buffer, value.index); + } else if (value is SKProductDiscountTypeMessage) { buffer.putUint8(130); - writeValue(buffer, value.encode()); - } else if (value is SKPaymentTransactionMessage) { + writeValue(buffer, value.index); + } else if (value is SKProductDiscountPaymentModeMessage) { buffer.putUint8(131); - writeValue(buffer, value.encode()); - } else if (value is SKPriceLocaleMessage) { + writeValue(buffer, value.index); + } else if (value is SKSubscriptionPeriodUnitMessage) { buffer.putUint8(132); - writeValue(buffer, value.encode()); - } else if (value is SKProductDiscountMessage) { + writeValue(buffer, value.index); + } else if (value is SKPaymentTransactionMessage) { buffer.putUint8(133); writeValue(buffer, value.encode()); - } else if (value is SKProductMessage) { + } else if (value is SKPaymentMessage) { buffer.putUint8(134); writeValue(buffer, value.encode()); - } else if (value is SKProductSubscriptionPeriodMessage) { + } else if (value is SKErrorMessage) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else if (value is SKProductsResponseMessage) { + } else if (value is SKPaymentDiscountMessage) { buffer.putUint8(136); writeValue(buffer, value.encode()); } else if (value is SKStorefrontMessage) { buffer.putUint8(137); writeValue(buffer, value.encode()); + } else if (value is SKProductsResponseMessage) { + buffer.putUint8(138); + writeValue(buffer, value.encode()); + } else if (value is SKProductMessage) { + buffer.putUint8(139); + writeValue(buffer, value.encode()); + } else if (value is SKPriceLocaleMessage) { + buffer.putUint8(140); + writeValue(buffer, value.encode()); + } else if (value is SKProductDiscountMessage) { + buffer.putUint8(141); + writeValue(buffer, value.encode()); + } else if (value is SKProductSubscriptionPeriodMessage) { + buffer.putUint8(142); + writeValue(buffer, value.encode()); } else { super.writeValue(buffer, value); } @@ -540,26 +541,46 @@ class _InAppPurchaseAPICodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: - return SKErrorMessage.decode(readValue(buffer)!); case 129: - return SKPaymentDiscountMessage.decode(readValue(buffer)!); + final int? value = readValue(buffer) as int?; + return value == null + ? null + : SKPaymentTransactionStateMessage.values[value]; case 130: - return SKPaymentMessage.decode(readValue(buffer)!); + final int? value = readValue(buffer) as int?; + return value == null + ? null + : SKProductDiscountTypeMessage.values[value]; case 131: - return SKPaymentTransactionMessage.decode(readValue(buffer)!); + final int? value = readValue(buffer) as int?; + return value == null + ? null + : SKProductDiscountPaymentModeMessage.values[value]; case 132: - return SKPriceLocaleMessage.decode(readValue(buffer)!); + final int? value = readValue(buffer) as int?; + return value == null + ? null + : SKSubscriptionPeriodUnitMessage.values[value]; case 133: - return SKProductDiscountMessage.decode(readValue(buffer)!); + return SKPaymentTransactionMessage.decode(readValue(buffer)!); case 134: - return SKProductMessage.decode(readValue(buffer)!); + return SKPaymentMessage.decode(readValue(buffer)!); case 135: - return SKProductSubscriptionPeriodMessage.decode(readValue(buffer)!); + return SKErrorMessage.decode(readValue(buffer)!); case 136: - return SKProductsResponseMessage.decode(readValue(buffer)!); + return SKPaymentDiscountMessage.decode(readValue(buffer)!); case 137: return SKStorefrontMessage.decode(readValue(buffer)!); + case 138: + return SKProductsResponseMessage.decode(readValue(buffer)!); + case 139: + return SKProductMessage.decode(readValue(buffer)!); + case 140: + return SKPriceLocaleMessage.decode(readValue(buffer)!); + case 141: + return SKProductDiscountMessage.decode(readValue(buffer)!); + case 142: + return SKProductSubscriptionPeriodMessage.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); } @@ -570,120 +591,124 @@ 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}) - : __pigeon_binaryMessenger = binaryMessenger; - final BinaryMessenger? __pigeon_binaryMessenger; + InAppPurchaseAPI( + {BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) + : pigeonVar_binaryMessenger = binaryMessenger, + pigeonVar_messageChannelSuffix = + messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + final BinaryMessenger? pigeonVar_binaryMessenger; + + static const MessageCodec pigeonChannelCodec = _PigeonCodec(); - static const MessageCodec pigeonChannelCodec = - _InAppPurchaseAPICodec(); + final String pigeonVar_messageChannelSuffix; /// Returns if the current device is able to make payments Future canMakePayments() async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.canMakePayments'; - final BasicMessageChannel __pigeon_channel = + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.canMakePayments$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send(null) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + 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: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); - } else if (__pigeon_replyList[0] == null) { + } else if (pigeonVar_replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (__pigeon_replyList[0] as bool?)!; + return (pigeonVar_replyList[0] as bool?)!; } } - Future> transactions() async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.transactions'; - final BasicMessageChannel __pigeon_channel = + Future> transactions() async { + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.transactions$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send(null) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + 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: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); - } else if (__pigeon_replyList[0] == null) { + } else if (pigeonVar_replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (__pigeon_replyList[0] as List?)! - .cast(); + return (pigeonVar_replyList[0] as List?)! + .cast(); } } Future storefront() async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.storefront'; - final BasicMessageChannel __pigeon_channel = + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.storefront$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send(null) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + 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: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); - } else if (__pigeon_replyList[0] == null) { + } else if (pigeonVar_replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (__pigeon_replyList[0] as SKStorefrontMessage?)!; + return (pigeonVar_replyList[0] as SKStorefrontMessage?)!; } } - Future addPayment(Map paymentMap) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.addPayment'; - final BasicMessageChannel __pigeon_channel = + 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( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([paymentMap]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([paymentMap]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -691,53 +716,53 @@ class InAppPurchaseAPI { } Future startProductRequest( - List productIdentifiers) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startProductRequest'; - final BasicMessageChannel __pigeon_channel = + List productIdentifiers) async { + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startProductRequest$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel + final List? pigeonVar_replyList = await pigeonVar_channel .send([productIdentifiers]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); - } else if (__pigeon_replyList[0] == null) { + } else if (pigeonVar_replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (__pigeon_replyList[0] as SKProductsResponseMessage?)!; + return (pigeonVar_replyList[0] as SKProductsResponseMessage?)!; } } - Future finishTransaction(Map finishMap) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.finishTransaction'; - final BasicMessageChannel __pigeon_channel = + 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( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send([finishMap]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + final List? pigeonVar_replyList = + await pigeonVar_channel.send([finishMap]) as List?; + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -745,23 +770,23 @@ class InAppPurchaseAPI { } Future restoreTransactions(String? applicationUserName) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.restoreTransactions'; - final BasicMessageChannel __pigeon_channel = + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.restoreTransactions$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel + final List? pigeonVar_replyList = await pigeonVar_channel .send([applicationUserName]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -769,23 +794,23 @@ class InAppPurchaseAPI { } Future presentCodeRedemptionSheet() async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.presentCodeRedemptionSheet'; - final BasicMessageChannel __pigeon_channel = + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.presentCodeRedemptionSheet$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send(null) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + 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: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -793,48 +818,47 @@ class InAppPurchaseAPI { } Future retrieveReceiptData() async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.retrieveReceiptData'; - final BasicMessageChannel __pigeon_channel = + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.retrieveReceiptData$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send(null) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + 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: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { - return (__pigeon_replyList[0] as String?); + return (pigeonVar_replyList[0] as String?); } } - Future refreshReceipt( - {Map? receiptProperties}) async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.refreshReceipt'; - final BasicMessageChannel __pigeon_channel = + 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( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = await __pigeon_channel + final List? pigeonVar_replyList = await pigeonVar_channel .send([receiptProperties]) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + if (pigeonVar_replyList == null) { + throw _createConnectionError(pigeonVar_channelName); + } else if (pigeonVar_replyList.length > 1) { throw PlatformException( - code: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -842,23 +866,23 @@ class InAppPurchaseAPI { } Future startObservingPaymentQueue() async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startObservingPaymentQueue'; - final BasicMessageChannel __pigeon_channel = + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startObservingPaymentQueue$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send(null) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + 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: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -866,23 +890,23 @@ class InAppPurchaseAPI { } Future stopObservingPaymentQueue() async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.stopObservingPaymentQueue'; - final BasicMessageChannel __pigeon_channel = + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.stopObservingPaymentQueue$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send(null) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + 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: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -890,23 +914,23 @@ class InAppPurchaseAPI { } Future registerPaymentQueueDelegate() async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.registerPaymentQueueDelegate'; - final BasicMessageChannel __pigeon_channel = + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.registerPaymentQueueDelegate$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send(null) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + 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: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -914,23 +938,23 @@ class InAppPurchaseAPI { } Future removePaymentQueueDelegate() async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.removePaymentQueueDelegate'; - final BasicMessageChannel __pigeon_channel = + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.removePaymentQueueDelegate$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send(null) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + 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: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; @@ -938,23 +962,23 @@ class InAppPurchaseAPI { } Future showPriceConsentIfNeeded() async { - const String __pigeon_channelName = - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.showPriceConsentIfNeeded'; - final BasicMessageChannel __pigeon_channel = + final String pigeonVar_channelName = + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.showPriceConsentIfNeeded$pigeonVar_messageChannelSuffix'; + final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - __pigeon_channelName, + pigeonVar_channelName, pigeonChannelCodec, - binaryMessenger: __pigeon_binaryMessenger, + binaryMessenger: pigeonVar_binaryMessenger, ); - final List? __pigeon_replyList = - await __pigeon_channel.send(null) as List?; - if (__pigeon_replyList == null) { - throw _createConnectionError(__pigeon_channelName); - } else if (__pigeon_replyList.length > 1) { + 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: __pigeon_replyList[0]! as String, - message: __pigeon_replyList[1] as String?, - details: __pigeon_replyList[2], + code: pigeonVar_replyList[0]! as String, + message: pigeonVar_replyList[1] as String?, + details: pigeonVar_replyList[2], ); } else { return; diff --git a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/sk2_pigeon.g.dart b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/sk2_pigeon.g.dart index d45d16074ef..b1e09a6585b 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/sk2_pigeon.g.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/sk2_pigeon.g.dart @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors. 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.0.0), do not edit directly. +// Autogenerated from Pigeon (v22.4.2), 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 @@ -143,9 +143,7 @@ class SK2SubscriptionInfoMessage { }); /// An array of all the promotional offers configured for this subscription. - /// This should be List but pigeon doesnt support - /// null-safe generics. https://github.com/flutter/flutter/issues/97848 - List promotionalOffers; + List promotionalOffers; /// The group identifier for this subscription. String subscriptionGroupID; @@ -165,7 +163,7 @@ class SK2SubscriptionInfoMessage { result as List; return SK2SubscriptionInfoMessage( promotionalOffers: - (result[0] as List?)!.cast(), + (result[0] as List?)!.cast(), subscriptionGroupID: result[1]! as String, subscriptionPeriod: result[2]! as SK2SubscriptionPeriodMessage, ); @@ -384,7 +382,7 @@ class InAppPurchase2API { } } - Future> products(List identifiers) async { + Future> products(List identifiers) async { final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.products$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = @@ -410,7 +408,7 @@ class InAppPurchase2API { ); } else { return (pigeonVar_replyList[0] as List?)! - .cast(); + .cast(); } } } diff --git a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_2_wrappers/sk2_product_wrapper.dart b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_2_wrappers/sk2_product_wrapper.dart index 9decfa433c9..f6ee473b13b 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_2_wrappers/sk2_product_wrapper.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_2_wrappers/sk2_product_wrapper.dart @@ -148,11 +148,7 @@ extension on SK2SubscriptionInfoMessage { SK2SubscriptionInfo convertFromPigeon() { return SK2SubscriptionInfo( subscriptionGroupID: subscriptionGroupID, - // Note that promotionalOffers should NOT be nullable, but is only declared - // so because of pigeon cannot handle non null lists. - // There should be NO NULLS. promotionalOffers: promotionalOffers - .whereType() .map((SK2SubscriptionOfferMessage offer) => offer.convertFromPigeon()) .toList(), diff --git a/packages/in_app_purchase/in_app_purchase_storekit/pigeons/sk2_pigeon.dart b/packages/in_app_purchase/in_app_purchase_storekit/pigeons/sk2_pigeon.dart index 941dd6dbb27..61cd742f6a7 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/pigeons/sk2_pigeon.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/pigeons/sk2_pigeon.dart @@ -69,9 +69,7 @@ class SK2SubscriptionInfoMessage { }); /// An array of all the promotional offers configured for this subscription. - /// This should be List but pigeon doesnt support - /// null-safe generics. https://github.com/flutter/flutter/issues/97848 - final List promotionalOffers; + final List promotionalOffers; /// The group identifier for this subscription. final String subscriptionGroupID; 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 ad1fac7ad97..b310730a44b 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/pubspec.yaml +++ b/packages/in_app_purchase/in_app_purchase_storekit/pubspec.yaml @@ -31,7 +31,7 @@ dev_dependencies: flutter_test: sdk: flutter json_serializable: ^6.0.0 - pigeon: ^22.0.0 + pigeon: ^22.4.2 test: ^1.16.0 topics: 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 6a5f6a53b64..8091dffc490 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 @@ -186,7 +186,7 @@ class FakeStoreKitPlatform implements TestInAppPurchaseApi { } @override - List transactions() { + List transactions() { throw UnimplementedError(); } @@ -309,7 +309,7 @@ class FakeStoreKit2Platform implements TestInAppPurchase2Api { } @override - Future> products(List identifiers) { + Future> products(List identifiers) { if (queryProductException != null) { throw queryProductException!; } @@ -320,11 +320,11 @@ class FakeStoreKit2Platform implements TestInAppPurchase2Api { products.add(validProducts[productID]!); } } - final List result = []; + final List result = []; for (final SK2Product p in products) { result.add(p.convertToPigeon()); } - return Future>.value(result); + return Future>.value(result); } } diff --git a/packages/in_app_purchase/in_app_purchase_storekit/test/in_app_purchase_storekit_platform_addtion_test.dart b/packages/in_app_purchase/in_app_purchase_storekit/test/in_app_purchase_storekit_platform_addtion_test.dart index 40068db75a7..dfa3c11ca6b 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/test/in_app_purchase_storekit_platform_addtion_test.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/test/in_app_purchase_storekit_platform_addtion_test.dart @@ -15,7 +15,7 @@ void main() { final FakeStoreKitPlatform fakeStoreKitPlatform = FakeStoreKitPlatform(); setUpAll(() { - TestInAppPurchaseApi.setup(fakeStoreKitPlatform); + TestInAppPurchaseApi.setUp(fakeStoreKitPlatform); }); group('present code redemption sheet', () { diff --git a/packages/in_app_purchase/in_app_purchase_storekit/test/in_app_purchase_storekit_platform_test.dart b/packages/in_app_purchase/in_app_purchase_storekit/test/in_app_purchase_storekit_platform_test.dart index 2da0e47070a..a255b4fa3bd 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/test/in_app_purchase_storekit_platform_test.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/test/in_app_purchase_storekit_platform_test.dart @@ -22,7 +22,7 @@ void main() { late InAppPurchaseStoreKitPlatform iapStoreKitPlatform; setUpAll(() { - TestInAppPurchaseApi.setup(fakeStoreKitPlatform); + TestInAppPurchaseApi.setUp(fakeStoreKitPlatform); }); setUp(() { diff --git a/packages/in_app_purchase/in_app_purchase_storekit/test/sk2_test_api.g.dart b/packages/in_app_purchase/in_app_purchase_storekit/test/sk2_test_api.g.dart index 21ad0789066..99ee0b8e2ef 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/test/sk2_test_api.g.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/test/sk2_test_api.g.dart @@ -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.0.0), do not edit directly. +// Autogenerated from Pigeon (v22.4.2), 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 @@ -96,7 +96,7 @@ abstract class TestInAppPurchase2Api { bool canMakePayments(); - Future> products(List identifiers); + Future> products(List identifiers); static void setUp( TestInAppPurchase2Api? api, { @@ -148,12 +148,12 @@ abstract class TestInAppPurchase2Api { assert(message != null, 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.products was null.'); final List args = (message as List?)!; - final List? arg_identifiers = - (args[0] as List?)?.cast(); + final List? arg_identifiers = + (args[0] as List?)?.cast(); assert(arg_identifiers != null, - 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.products was null, expected non-null List.'); + 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.products was null, expected non-null List.'); try { - final List output = + final List output = await api.products(arg_identifiers!); return [output]; } on PlatformException catch (e) { 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 f7fe5283d94..b774552f84b 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 @@ -15,7 +15,7 @@ void main() { final FakeStoreKitPlatform fakeStoreKitPlatform = FakeStoreKitPlatform(); setUpAll(() { - TestInAppPurchaseApi.setup(fakeStoreKitPlatform); + TestInAppPurchaseApi.setUp(fakeStoreKitPlatform); }); setUp(() {}); @@ -235,7 +235,7 @@ class FakeStoreKitPlatform implements TestInAppPurchaseApi { } @override - List transactions() => + List transactions() => [dummyTransactionMessage]; @override diff --git a/packages/in_app_purchase/in_app_purchase_storekit/test/store_kit_wrappers/sk_payment_queue_delegate_api_test.dart b/packages/in_app_purchase/in_app_purchase_storekit/test/store_kit_wrappers/sk_payment_queue_delegate_api_test.dart index 03c9fda381c..f9efd427bfc 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/test/store_kit_wrappers/sk_payment_queue_delegate_api_test.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/test/store_kit_wrappers/sk_payment_queue_delegate_api_test.dart @@ -15,7 +15,7 @@ void main() { final FakeStoreKitPlatform fakeStoreKitPlatform = FakeStoreKitPlatform(); setUpAll(() { - TestInAppPurchaseApi.setup(fakeStoreKitPlatform); + TestInAppPurchaseApi.setUp(fakeStoreKitPlatform); }); test( 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 6b0c9a77ab4..2092930d208 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 (v16.0.5), do not edit directly. +// Autogenerated from Pigeon (v22.4.2), 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,40 +13,55 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:in_app_purchase_storekit/src/messages.g.dart'; -class _TestInAppPurchaseApiCodec extends StandardMessageCodec { - const _TestInAppPurchaseApiCodec(); +class _PigeonCodec extends StandardMessageCodec { + const _PigeonCodec(); @override void writeValue(WriteBuffer buffer, Object? value) { - if (value is SKErrorMessage) { - buffer.putUint8(128); - writeValue(buffer, value.encode()); - } else if (value is SKPaymentDiscountMessage) { + if (value is int) { + buffer.putUint8(4); + buffer.putInt64(value); + } else if (value is SKPaymentTransactionStateMessage) { buffer.putUint8(129); - writeValue(buffer, value.encode()); - } else if (value is SKPaymentMessage) { + writeValue(buffer, value.index); + } else if (value is SKProductDiscountTypeMessage) { buffer.putUint8(130); - writeValue(buffer, value.encode()); - } else if (value is SKPaymentTransactionMessage) { + writeValue(buffer, value.index); + } else if (value is SKProductDiscountPaymentModeMessage) { buffer.putUint8(131); - writeValue(buffer, value.encode()); - } else if (value is SKPriceLocaleMessage) { + writeValue(buffer, value.index); + } else if (value is SKSubscriptionPeriodUnitMessage) { buffer.putUint8(132); - writeValue(buffer, value.encode()); - } else if (value is SKProductDiscountMessage) { + writeValue(buffer, value.index); + } else if (value is SKPaymentTransactionMessage) { buffer.putUint8(133); writeValue(buffer, value.encode()); - } else if (value is SKProductMessage) { + } else if (value is SKPaymentMessage) { buffer.putUint8(134); writeValue(buffer, value.encode()); - } else if (value is SKProductSubscriptionPeriodMessage) { + } else if (value is SKErrorMessage) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else if (value is SKProductsResponseMessage) { + } else if (value is SKPaymentDiscountMessage) { buffer.putUint8(136); writeValue(buffer, value.encode()); } else if (value is SKStorefrontMessage) { buffer.putUint8(137); writeValue(buffer, value.encode()); + } else if (value is SKProductsResponseMessage) { + buffer.putUint8(138); + writeValue(buffer, value.encode()); + } else if (value is SKProductMessage) { + buffer.putUint8(139); + writeValue(buffer, value.encode()); + } else if (value is SKPriceLocaleMessage) { + buffer.putUint8(140); + writeValue(buffer, value.encode()); + } else if (value is SKProductDiscountMessage) { + buffer.putUint8(141); + writeValue(buffer, value.encode()); + } else if (value is SKProductSubscriptionPeriodMessage) { + buffer.putUint8(142); + writeValue(buffer, value.encode()); } else { super.writeValue(buffer, value); } @@ -55,26 +70,46 @@ class _TestInAppPurchaseApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: - return SKErrorMessage.decode(readValue(buffer)!); case 129: - return SKPaymentDiscountMessage.decode(readValue(buffer)!); + final int? value = readValue(buffer) as int?; + return value == null + ? null + : SKPaymentTransactionStateMessage.values[value]; case 130: - return SKPaymentMessage.decode(readValue(buffer)!); + final int? value = readValue(buffer) as int?; + return value == null + ? null + : SKProductDiscountTypeMessage.values[value]; case 131: - return SKPaymentTransactionMessage.decode(readValue(buffer)!); + final int? value = readValue(buffer) as int?; + return value == null + ? null + : SKProductDiscountPaymentModeMessage.values[value]; case 132: - return SKPriceLocaleMessage.decode(readValue(buffer)!); + final int? value = readValue(buffer) as int?; + return value == null + ? null + : SKSubscriptionPeriodUnitMessage.values[value]; case 133: - return SKProductDiscountMessage.decode(readValue(buffer)!); + return SKPaymentTransactionMessage.decode(readValue(buffer)!); case 134: - return SKProductMessage.decode(readValue(buffer)!); + return SKPaymentMessage.decode(readValue(buffer)!); case 135: - return SKProductSubscriptionPeriodMessage.decode(readValue(buffer)!); + return SKErrorMessage.decode(readValue(buffer)!); case 136: - return SKProductsResponseMessage.decode(readValue(buffer)!); + return SKPaymentDiscountMessage.decode(readValue(buffer)!); case 137: return SKStorefrontMessage.decode(readValue(buffer)!); + case 138: + return SKProductsResponseMessage.decode(readValue(buffer)!); + case 139: + return SKProductMessage.decode(readValue(buffer)!); + case 140: + return SKPriceLocaleMessage.decode(readValue(buffer)!); + case 141: + return SKProductDiscountMessage.decode(readValue(buffer)!); + case 142: + return SKProductSubscriptionPeriodMessage.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); } @@ -84,22 +119,21 @@ class _TestInAppPurchaseApiCodec extends StandardMessageCodec { abstract class TestInAppPurchaseApi { static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; - static const MessageCodec pigeonChannelCodec = - _TestInAppPurchaseApiCodec(); + static const MessageCodec pigeonChannelCodec = _PigeonCodec(); /// Returns if the current device is able to make payments bool canMakePayments(); - List transactions(); + List transactions(); SKStorefrontMessage storefront(); - void addPayment(Map paymentMap); + void addPayment(Map paymentMap); Future startProductRequest( - List productIdentifiers); + List productIdentifiers); - void finishTransaction(Map finishMap); + void finishTransaction(Map finishMap); void restoreTransactions(String? applicationUserName); @@ -107,7 +141,7 @@ abstract class TestInAppPurchaseApi { String? retrieveReceiptData(); - Future refreshReceipt({Map? receiptProperties}); + Future refreshReceipt({Map? receiptProperties}); void startObservingPaymentQueue(); @@ -119,20 +153,26 @@ abstract class TestInAppPurchaseApi { void showPriceConsentIfNeeded(); - static void setup(TestInAppPurchaseApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setUp( + TestInAppPurchaseApi? api, { + BinaryMessenger? binaryMessenger, + String messageChannelSuffix = '', + }) { + messageChannelSuffix = + messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.canMakePayments', + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.canMakePayments$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, null); + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, + .setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { try { final bool output = api.canMakePayments(); @@ -147,21 +187,21 @@ abstract class TestInAppPurchaseApi { } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.transactions', + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.transactions$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, null); + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, + .setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { try { - final List output = - api.transactions(); + final List output = api.transactions(); return [output]; } on PlatformException catch (e) { return wrapResponse(error: e); @@ -173,17 +213,18 @@ abstract class TestInAppPurchaseApi { } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.storefront', + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.storefront$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, null); + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, + .setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { try { final SKStorefrontMessage output = api.storefront(); @@ -198,25 +239,26 @@ abstract class TestInAppPurchaseApi { } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.addPayment', + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.addPayment$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, null); + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, + .setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { assert(message != 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.'); + 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.addPayment was null, expected non-null Map.'); try { api.addPayment(arg_paymentMap!); return wrapResponse(empty: true); @@ -230,25 +272,26 @@ abstract class TestInAppPurchaseApi { } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startProductRequest', + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startProductRequest$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, null); + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, + .setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { assert(message != 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.'); + '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!); @@ -263,25 +306,26 @@ abstract class TestInAppPurchaseApi { } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.finishTransaction', + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.finishTransaction$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, null); + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, + .setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { assert(message != 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.'); + 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.finishTransaction was null, expected non-null Map.'); try { api.finishTransaction(arg_finishMap!); return wrapResponse(empty: true); @@ -295,17 +339,18 @@ abstract class TestInAppPurchaseApi { } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.restoreTransactions', + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.restoreTransactions$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, null); + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, + .setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { assert(message != null, 'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.restoreTransactions was null.'); @@ -324,17 +369,18 @@ abstract class TestInAppPurchaseApi { } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.presentCodeRedemptionSheet', + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.presentCodeRedemptionSheet$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, null); + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, + .setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { try { api.presentCodeRedemptionSheet(); @@ -349,17 +395,18 @@ abstract class TestInAppPurchaseApi { } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.retrieveReceiptData', + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.retrieveReceiptData$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, null); + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, + .setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { try { final String? output = api.retrieveReceiptData(); @@ -374,23 +421,24 @@ abstract class TestInAppPurchaseApi { } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.refreshReceipt', + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.refreshReceipt$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, null); + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, + .setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { assert(message != 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); @@ -404,17 +452,18 @@ abstract class TestInAppPurchaseApi { } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startObservingPaymentQueue', + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.startObservingPaymentQueue$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, null); + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, + .setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { try { api.startObservingPaymentQueue(); @@ -429,17 +478,18 @@ abstract class TestInAppPurchaseApi { } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.stopObservingPaymentQueue', + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.stopObservingPaymentQueue$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, null); + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, + .setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { try { api.stopObservingPaymentQueue(); @@ -454,17 +504,18 @@ abstract class TestInAppPurchaseApi { } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.registerPaymentQueueDelegate', + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.registerPaymentQueueDelegate$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, null); + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, + .setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { try { api.registerPaymentQueueDelegate(); @@ -479,17 +530,18 @@ abstract class TestInAppPurchaseApi { } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.removePaymentQueueDelegate', + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.removePaymentQueueDelegate$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, null); + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, + .setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { try { api.removePaymentQueueDelegate(); @@ -504,17 +556,18 @@ abstract class TestInAppPurchaseApi { } } { - final BasicMessageChannel __pigeon_channel = BasicMessageChannel< + final BasicMessageChannel< + Object?> pigeonVar_channel = BasicMessageChannel< Object?>( - 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.showPriceConsentIfNeeded', + 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchaseAPI.showPriceConsentIfNeeded$messageChannelSuffix', pigeonChannelCodec, binaryMessenger: binaryMessenger); if (api == null) { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, null); + .setMockDecodedMessageHandler(pigeonVar_channel, null); } else { _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(__pigeon_channel, + .setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { try { api.showPriceConsentIfNeeded(); From bb7a2856c9c27787f51d58cd35c151fccccd71d9 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 8 Oct 2024 11:39:54 -0400 Subject: [PATCH 02/10] Update sk1 --- .../lib/src/messages.g.dart | 16 ++++++++-------- .../pigeons/messages.dart | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) 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 bd41a66cdd3..8679df86f74 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 @@ -198,7 +198,7 @@ class SKErrorMessage { String domain; - Map? userInfo; + Map? userInfo; Object encode() { return [ @@ -213,7 +213,7 @@ class SKErrorMessage { return SKErrorMessage( code: result[0]! as int, domain: result[1]! as String, - userInfo: (result[2] as Map?)?.cast(), + userInfo: (result[2] as Map?)?.cast(), ); } } @@ -291,9 +291,9 @@ class SKProductsResponseMessage { this.invalidProductIdentifiers, }); - List? products; + List? products; - List? invalidProductIdentifiers; + List? invalidProductIdentifiers; Object encode() { return [ @@ -305,8 +305,8 @@ class SKProductsResponseMessage { static SKProductsResponseMessage decode(Object result) { result as List; return SKProductsResponseMessage( - products: (result[0] as List?)?.cast(), - invalidProductIdentifiers: (result[1] as List?)?.cast(), + products: (result[0] as List?)?.cast(), + invalidProductIdentifiers: (result[1] as List?)?.cast(), ); } } @@ -340,7 +340,7 @@ class SKProductMessage { SKProductDiscountMessage? introductoryPrice; - List? discounts; + List? discounts; Object encode() { return [ @@ -368,7 +368,7 @@ class SKProductMessage { subscriptionPeriod: result[6] as SKProductSubscriptionPeriodMessage?, introductoryPrice: result[7] as SKProductDiscountMessage?, discounts: - (result[8] as List?)?.cast(), + (result[8] as List?)?.cast(), ); } } 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 07c1c3d2d3b..63a1accfe4d 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 @@ -91,7 +91,7 @@ class SKErrorMessage { final int code; final String domain; - final Map? userInfo; + final Map? userInfo; } class SKPaymentDiscountMessage { @@ -123,8 +123,8 @@ class SKStorefrontMessage { class SKProductsResponseMessage { const SKProductsResponseMessage( {required this.products, required this.invalidProductIdentifiers}); - final List? products; - final List? invalidProductIdentifiers; + final List? products; + final List? invalidProductIdentifiers; } class SKProductMessage { @@ -150,7 +150,7 @@ class SKProductMessage { final String price; final SKProductSubscriptionPeriodMessage? subscriptionPeriod; final SKProductDiscountMessage? introductoryPrice; - final List? discounts; + final List? discounts; } class SKPriceLocaleMessage { From c7bd3ebe164bc8ec819186a0560f2a752bb9e855 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 8 Oct 2024 11:50:59 -0400 Subject: [PATCH 03/10] Manual sk1 cleanup --- .../sk_payment_queue_wrapper.dart | 4 ++-- .../sk_product_wrapper.dart | 19 ++++++++----------- .../store_kit_wrappers/sk_request_maker.dart | 2 +- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_wrappers/sk_payment_queue_wrapper.dart b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_wrappers/sk_payment_queue_wrapper.dart index 8f1af1c6404..138ecc8b747 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_wrappers/sk_payment_queue_wrapper.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_wrappers/sk_payment_queue_wrapper.dart @@ -416,8 +416,8 @@ class SKPaymentWrapper { } /// Creates a Map object describes the payment object. - Map toMap() { - return { + Map toMap() { + return { 'productIdentifier': productIdentifier, 'applicationUsername': applicationUsername, 'requestData': requestData, diff --git a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_wrappers/sk_product_wrapper.dart b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_wrappers/sk_product_wrapper.dart index ff49758107d..95698271c3f 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_wrappers/sk_product_wrapper.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_wrappers/sk_product_wrapper.dart @@ -72,11 +72,9 @@ class SkProductResponseWrapper { SKProductsResponseMessage msg) { return SkProductResponseWrapper( products: msg.products! - .map((SKProductMessage? e) => SKProductWrapper.convertFromPigeon(e!)) + .map((SKProductMessage e) => SKProductWrapper.convertFromPigeon(e)) .toList(), - invalidProductIdentifiers: msg.invalidProductIdentifiers != null - ? msg.invalidProductIdentifiers!.cast() - : [], + invalidProductIdentifiers: msg.invalidProductIdentifiers ?? [], ); } @@ -86,10 +84,9 @@ class SkProductResponseWrapper { SkProductResponseWrapper wrapper) { return SKProductsResponseMessage( products: wrapper.products - .map((SKProductWrapper? e) => SKProductWrapper.convertToPigeon(e!)) + .map((SKProductWrapper e) => SKProductWrapper.convertToPigeon(e)) .toList(), - invalidProductIdentifiers: - wrapper.invalidProductIdentifiers.cast()); + invalidProductIdentifiers: wrapper.invalidProductIdentifiers); } } @@ -563,8 +560,8 @@ class SKProductWrapper { : null, discounts: msg.discounts != null ? msg.discounts! - .map((SKProductDiscountMessage? e) => - SKProductDiscountWrapper.convertFromPigeon(e!)) + .map((SKProductDiscountMessage e) => + SKProductDiscountWrapper.convertFromPigeon(e)) .toList() : []); } @@ -587,8 +584,8 @@ class SKProductWrapper { wrapper.introductoryPrice!) : null, discounts: wrapper.discounts - .map((SKProductDiscountWrapper? e) => - SKProductDiscountWrapper.convertToPigeon(e!)) + .map((SKProductDiscountWrapper e) => + SKProductDiscountWrapper.convertToPigeon(e)) .toList()); } } 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 5a16f261cdd..9075db9157a 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 @@ -52,7 +52,7 @@ class SKRequestMaker { /// * isRevoked: whether the receipt has been revoked. /// * isVolumePurchase: whether the receipt is a Volume Purchase Plan receipt. Future startRefreshReceiptRequest( - {Map? receiptProperties}) { + {Map? receiptProperties}) { return _hostApi.refreshReceipt(receiptProperties: receiptProperties); } } From 1c4b7f8f4a5fa3f1ebcd013a7f840f5850536af0 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 8 Oct 2024 11:51:17 -0400 Subject: [PATCH 04/10] Version bump --- .../in_app_purchase/in_app_purchase_storekit/CHANGELOG.md | 4 ++++ .../in_app_purchase/in_app_purchase_storekit/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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 f072c092770..456788e0cc5 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.18+2 + +* Updates Pigeon for non-nullable collection type support. + ## 0.3.18+1 * Adds support for StoreKit2's `canMakePayments` and `products` 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 b310730a44b..af6f20ac725 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.18+1 +version: 0.3.18+2 environment: sdk: ^3.3.0 From 6de3dfd70078c7fc630fe634e15029309e6a0d91 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 8 Oct 2024 12:02:02 -0400 Subject: [PATCH 05/10] Add missing Obj-C prefix --- .../darwin/Classes/messages.g.h | 204 ++++----- .../darwin/Classes/messages.g.m | 430 +++++++++--------- .../pigeons/messages.dart | 3 + 3 files changed, 321 insertions(+), 316 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 2ad1f03f7e9..a6059f269d7 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 @@ -13,117 +13,117 @@ NS_ASSUME_NONNULL_BEGIN -typedef NS_ENUM(NSUInteger, SKPaymentTransactionStateMessage) { +typedef NS_ENUM(NSUInteger, FIASKPaymentTransactionStateMessage) { /// Indicates the transaction is being processed in App Store. /// /// You should update your UI to indicate that you are waiting for the /// transaction to update to another state. Never complete a transaction that /// is still in a purchasing state. - SKPaymentTransactionStateMessagePurchasing = 0, + FIASKPaymentTransactionStateMessagePurchasing = 0, /// The user's payment has been succesfully processed. /// /// You should provide the user the content that they purchased. - SKPaymentTransactionStateMessagePurchased = 1, + FIASKPaymentTransactionStateMessagePurchased = 1, /// The transaction failed. /// /// Check the [PaymentTransactionWrapper.error] property from /// [PaymentTransactionWrapper] for details. - SKPaymentTransactionStateMessageFailed = 2, + FIASKPaymentTransactionStateMessageFailed = 2, /// This transaction is restoring content previously purchased by the user. /// /// The previous transaction information can be obtained in /// [PaymentTransactionWrapper.originalTransaction] from /// [PaymentTransactionWrapper]. - SKPaymentTransactionStateMessageRestored = 3, + FIASKPaymentTransactionStateMessageRestored = 3, /// 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. - SKPaymentTransactionStateMessageDeferred = 4, + FIASKPaymentTransactionStateMessageDeferred = 4, /// Indicates the transaction is in an unspecified state. - SKPaymentTransactionStateMessageUnspecified = 5, + FIASKPaymentTransactionStateMessageUnspecified = 5, }; -/// Wrapper for SKPaymentTransactionStateMessage to allow for nullability. -@interface SKPaymentTransactionStateMessageBox : NSObject -@property(nonatomic, assign) SKPaymentTransactionStateMessage value; -- (instancetype)initWithValue:(SKPaymentTransactionStateMessage)value; +/// Wrapper for FIASKPaymentTransactionStateMessage to allow for nullability. +@interface FIASKPaymentTransactionStateMessageBox : NSObject +@property(nonatomic, assign) FIASKPaymentTransactionStateMessage value; +- (instancetype)initWithValue:(FIASKPaymentTransactionStateMessage)value; @end -typedef NS_ENUM(NSUInteger, SKProductDiscountTypeMessage) { +typedef NS_ENUM(NSUInteger, FIASKProductDiscountTypeMessage) { /// A constant indicating the discount type is an introductory offer. - SKProductDiscountTypeMessageIntroductory = 0, + FIASKProductDiscountTypeMessageIntroductory = 0, /// A constant indicating the discount type is a promotional offer. - SKProductDiscountTypeMessageSubscription = 1, + FIASKProductDiscountTypeMessageSubscription = 1, }; -/// Wrapper for SKProductDiscountTypeMessage to allow for nullability. -@interface SKProductDiscountTypeMessageBox : NSObject -@property(nonatomic, assign) SKProductDiscountTypeMessage value; -- (instancetype)initWithValue:(SKProductDiscountTypeMessage)value; +/// Wrapper for FIASKProductDiscountTypeMessage to allow for nullability. +@interface FIASKProductDiscountTypeMessageBox : NSObject +@property(nonatomic, assign) FIASKProductDiscountTypeMessage value; +- (instancetype)initWithValue:(FIASKProductDiscountTypeMessage)value; @end -typedef NS_ENUM(NSUInteger, SKProductDiscountPaymentModeMessage) { +typedef NS_ENUM(NSUInteger, FIASKProductDiscountPaymentModeMessage) { /// Allows user to pay the discounted price at each payment period. - SKProductDiscountPaymentModeMessagePayAsYouGo = 0, + FIASKProductDiscountPaymentModeMessagePayAsYouGo = 0, /// Allows user to pay the discounted price upfront and receive the product for the rest of time /// that was paid for. - SKProductDiscountPaymentModeMessagePayUpFront = 1, + FIASKProductDiscountPaymentModeMessagePayUpFront = 1, /// User pays nothing during the discounted period. - SKProductDiscountPaymentModeMessageFreeTrial = 2, + FIASKProductDiscountPaymentModeMessageFreeTrial = 2, /// Unspecified mode. - SKProductDiscountPaymentModeMessageUnspecified = 3, + FIASKProductDiscountPaymentModeMessageUnspecified = 3, }; -/// Wrapper for SKProductDiscountPaymentModeMessage to allow for nullability. -@interface SKProductDiscountPaymentModeMessageBox : NSObject -@property(nonatomic, assign) SKProductDiscountPaymentModeMessage value; -- (instancetype)initWithValue:(SKProductDiscountPaymentModeMessage)value; +/// Wrapper for FIASKProductDiscountPaymentModeMessage to allow for nullability. +@interface FIASKProductDiscountPaymentModeMessageBox : NSObject +@property(nonatomic, assign) FIASKProductDiscountPaymentModeMessage value; +- (instancetype)initWithValue:(FIASKProductDiscountPaymentModeMessage)value; @end -typedef NS_ENUM(NSUInteger, SKSubscriptionPeriodUnitMessage) { - SKSubscriptionPeriodUnitMessageDay = 0, - SKSubscriptionPeriodUnitMessageWeek = 1, - SKSubscriptionPeriodUnitMessageMonth = 2, - SKSubscriptionPeriodUnitMessageYear = 3, +typedef NS_ENUM(NSUInteger, FIASKSubscriptionPeriodUnitMessage) { + FIASKSubscriptionPeriodUnitMessageDay = 0, + FIASKSubscriptionPeriodUnitMessageWeek = 1, + FIASKSubscriptionPeriodUnitMessageMonth = 2, + FIASKSubscriptionPeriodUnitMessageYear = 3, }; -/// Wrapper for SKSubscriptionPeriodUnitMessage to allow for nullability. -@interface SKSubscriptionPeriodUnitMessageBox : NSObject -@property(nonatomic, assign) SKSubscriptionPeriodUnitMessage value; -- (instancetype)initWithValue:(SKSubscriptionPeriodUnitMessage)value; +/// Wrapper for FIASKSubscriptionPeriodUnitMessage to allow for nullability. +@interface FIASKSubscriptionPeriodUnitMessageBox : NSObject +@property(nonatomic, assign) FIASKSubscriptionPeriodUnitMessage value; +- (instancetype)initWithValue:(FIASKSubscriptionPeriodUnitMessage)value; @end -@class SKPaymentTransactionMessage; -@class SKPaymentMessage; -@class SKErrorMessage; -@class SKPaymentDiscountMessage; -@class SKStorefrontMessage; -@class SKProductsResponseMessage; -@class SKProductMessage; -@class SKPriceLocaleMessage; -@class SKProductDiscountMessage; -@class SKProductSubscriptionPeriodMessage; +@class FIASKPaymentTransactionMessage; +@class FIASKPaymentMessage; +@class FIASKErrorMessage; +@class FIASKPaymentDiscountMessage; +@class FIASKStorefrontMessage; +@class FIASKProductsResponseMessage; +@class FIASKProductMessage; +@class FIASKPriceLocaleMessage; +@class FIASKProductDiscountMessage; +@class FIASKProductSubscriptionPeriodMessage; -@interface SKPaymentTransactionMessage : NSObject +@interface FIASKPaymentTransactionMessage : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; -+ (instancetype)makeWithPayment:(SKPaymentMessage *)payment - transactionState:(SKPaymentTransactionStateMessage)transactionState - originalTransaction:(nullable SKPaymentTransactionMessage *)originalTransaction ++ (instancetype)makeWithPayment:(FIASKPaymentMessage *)payment + transactionState:(FIASKPaymentTransactionStateMessage)transactionState + originalTransaction:(nullable FIASKPaymentTransactionMessage *)originalTransaction transactionTimeStamp:(nullable NSNumber *)transactionTimeStamp transactionIdentifier:(nullable NSString *)transactionIdentifier - error:(nullable SKErrorMessage *)error; -@property(nonatomic, strong) SKPaymentMessage *payment; -@property(nonatomic, assign) SKPaymentTransactionStateMessage transactionState; -@property(nonatomic, strong, nullable) SKPaymentTransactionMessage *originalTransaction; + 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) SKErrorMessage *error; +@property(nonatomic, strong, nullable) FIASKErrorMessage *error; @end -@interface SKPaymentMessage : NSObject +@interface FIASKPaymentMessage : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithProductIdentifier:(NSString *)productIdentifier @@ -131,16 +131,16 @@ typedef NS_ENUM(NSUInteger, SKSubscriptionPeriodUnitMessage) { requestData:(nullable NSString *)requestData quantity:(NSInteger)quantity simulatesAskToBuyInSandbox:(BOOL)simulatesAskToBuyInSandbox - paymentDiscount:(nullable SKPaymentDiscountMessage *)paymentDiscount; + 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) SKPaymentDiscountMessage *paymentDiscount; +@property(nonatomic, strong, nullable) FIASKPaymentDiscountMessage *paymentDiscount; @end -@interface SKErrorMessage : NSObject +@interface FIASKErrorMessage : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithCode:(NSInteger)code @@ -151,7 +151,7 @@ typedef NS_ENUM(NSUInteger, SKSubscriptionPeriodUnitMessage) { @property(nonatomic, copy, nullable) NSDictionary *userInfo; @end -@interface SKPaymentDiscountMessage : NSObject +@interface FIASKPaymentDiscountMessage : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithIdentifier:(NSString *)identifier @@ -166,7 +166,7 @@ typedef NS_ENUM(NSUInteger, SKSubscriptionPeriodUnitMessage) { @property(nonatomic, assign) NSInteger timestamp; @end -@interface SKStorefrontMessage : NSObject +@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; @@ -174,38 +174,38 @@ typedef NS_ENUM(NSUInteger, SKSubscriptionPeriodUnitMessage) { @property(nonatomic, copy) NSString *identifier; @end -@interface SKProductsResponseMessage : NSObject -+ (instancetype)makeWithProducts:(nullable NSArray *)products +@interface FIASKProductsResponseMessage : NSObject ++ (instancetype)makeWithProducts:(nullable NSArray *)products invalidProductIdentifiers:(nullable NSArray *)invalidProductIdentifiers; -@property(nonatomic, copy, nullable) NSArray *products; +@property(nonatomic, copy, nullable) NSArray *products; @property(nonatomic, copy, nullable) NSArray *invalidProductIdentifiers; @end -@interface SKProductMessage : NSObject +@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:(SKPriceLocaleMessage *)priceLocale - subscriptionGroupIdentifier:(nullable NSString *)subscriptionGroupIdentifier - price:(NSString *)price - subscriptionPeriod: - (nullable SKProductSubscriptionPeriodMessage *)subscriptionPeriod - introductoryPrice:(nullable SKProductDiscountMessage *)introductoryPrice - discounts:(nullable NSArray *)discounts; ++ (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) SKPriceLocaleMessage *priceLocale; +@property(nonatomic, strong) FIASKPriceLocaleMessage *priceLocale; @property(nonatomic, copy, nullable) NSString *subscriptionGroupIdentifier; @property(nonatomic, copy) NSString *price; -@property(nonatomic, strong, nullable) SKProductSubscriptionPeriodMessage *subscriptionPeriod; -@property(nonatomic, strong, nullable) SKProductDiscountMessage *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 SKPriceLocaleMessage : NSObject +@interface FIASKPriceLocaleMessage : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithCurrencySymbol:(NSString *)currencySymbol @@ -219,51 +219,51 @@ typedef NS_ENUM(NSUInteger, SKSubscriptionPeriodUnitMessage) { @property(nonatomic, copy) NSString *countryCode; @end -@interface SKProductDiscountMessage : NSObject +@interface FIASKProductDiscountMessage : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithPrice:(NSString *)price - priceLocale:(SKPriceLocaleMessage *)priceLocale + priceLocale:(FIASKPriceLocaleMessage *)priceLocale numberOfPeriods:(NSInteger)numberOfPeriods - paymentMode:(SKProductDiscountPaymentModeMessage)paymentMode - subscriptionPeriod:(SKProductSubscriptionPeriodMessage *)subscriptionPeriod + paymentMode:(FIASKProductDiscountPaymentModeMessage)paymentMode + subscriptionPeriod:(FIASKProductSubscriptionPeriodMessage *)subscriptionPeriod identifier:(nullable NSString *)identifier - type:(SKProductDiscountTypeMessage)type; + type:(FIASKProductDiscountTypeMessage)type; @property(nonatomic, copy) NSString *price; -@property(nonatomic, strong) SKPriceLocaleMessage *priceLocale; +@property(nonatomic, strong) FIASKPriceLocaleMessage *priceLocale; @property(nonatomic, assign) NSInteger numberOfPeriods; -@property(nonatomic, assign) SKProductDiscountPaymentModeMessage paymentMode; -@property(nonatomic, strong) SKProductSubscriptionPeriodMessage *subscriptionPeriod; +@property(nonatomic, assign) FIASKProductDiscountPaymentModeMessage paymentMode; +@property(nonatomic, strong) FIASKProductSubscriptionPeriodMessage *subscriptionPeriod; @property(nonatomic, copy, nullable) NSString *identifier; -@property(nonatomic, assign) SKProductDiscountTypeMessage type; +@property(nonatomic, assign) FIASKProductDiscountTypeMessage type; @end -@interface SKProductSubscriptionPeriodMessage : NSObject +@interface FIASKProductSubscriptionPeriodMessage : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithNumberOfUnits:(NSInteger)numberOfUnits - unit:(SKSubscriptionPeriodUnitMessage)unit; + unit:(FIASKSubscriptionPeriodUnitMessage)unit; @property(nonatomic, assign) NSInteger numberOfUnits; -@property(nonatomic, assign) SKSubscriptionPeriodUnitMessage unit; +@property(nonatomic, assign) FIASKSubscriptionPeriodUnitMessage unit; @end /// The codec used by all APIs. -NSObject *nullGetMessagesCodec(void); +NSObject *FIAGetMessagesCodec(void); -@protocol InAppPurchaseAPI +@protocol FIAInAppPurchaseAPI /// Returns if the current device is able to make payments /// /// @return `nil` only when `error != nil`. - (nullable NSNumber *)canMakePaymentsWithError:(FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable NSArray *)transactionsWithError: +- (nullable NSArray *)transactionsWithError: (FlutterError *_Nullable *_Nonnull)error; /// @return `nil` only when `error != nil`. -- (nullable SKStorefrontMessage *)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 (^)(SKProductsResponseMessage *_Nullable, + completion:(void (^)(FIASKProductsResponseMessage *_Nullable, FlutterError *_Nullable))completion; - (void)finishTransactionFinishMap:(NSDictionary *)finishMap error:(FlutterError *_Nullable *_Nonnull)error; @@ -280,11 +280,11 @@ NSObject *nullGetMessagesCodec(void); - (void)showPriceConsentIfNeededWithError:(FlutterError *_Nullable *_Nonnull)error; @end -extern void SetUpInAppPurchaseAPI(id binaryMessenger, - NSObject *_Nullable api); +extern void SetUpFIAInAppPurchaseAPI(id binaryMessenger, + NSObject *_Nullable api); -extern void SetUpInAppPurchaseAPIWithSuffix(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 1e36142208a..62988eb04fe 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 @@ -30,8 +30,8 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) { return (result == [NSNull null]) ? nil : result; } -@implementation SKPaymentTransactionStateMessageBox -- (instancetype)initWithValue:(SKPaymentTransactionStateMessage)value { +@implementation FIASKPaymentTransactionStateMessageBox +- (instancetype)initWithValue:(FIASKPaymentTransactionStateMessage)value { self = [super init]; if (self) { _value = value; @@ -40,8 +40,8 @@ - (instancetype)initWithValue:(SKPaymentTransactionStateMessage)value { } @end -@implementation SKProductDiscountTypeMessageBox -- (instancetype)initWithValue:(SKProductDiscountTypeMessage)value { +@implementation FIASKProductDiscountTypeMessageBox +- (instancetype)initWithValue:(FIASKProductDiscountTypeMessage)value { self = [super init]; if (self) { _value = value; @@ -50,8 +50,8 @@ - (instancetype)initWithValue:(SKProductDiscountTypeMessage)value { } @end -@implementation SKProductDiscountPaymentModeMessageBox -- (instancetype)initWithValue:(SKProductDiscountPaymentModeMessage)value { +@implementation FIASKProductDiscountPaymentModeMessageBox +- (instancetype)initWithValue:(FIASKProductDiscountPaymentModeMessage)value { self = [super init]; if (self) { _value = value; @@ -60,8 +60,8 @@ - (instancetype)initWithValue:(SKProductDiscountPaymentModeMessage)value { } @end -@implementation SKSubscriptionPeriodUnitMessageBox -- (instancetype)initWithValue:(SKSubscriptionPeriodUnitMessage)value { +@implementation FIASKSubscriptionPeriodUnitMessageBox +- (instancetype)initWithValue:(FIASKSubscriptionPeriodUnitMessage)value { self = [super init]; if (self) { _value = value; @@ -70,74 +70,74 @@ - (instancetype)initWithValue:(SKSubscriptionPeriodUnitMessage)value { } @end -@interface SKPaymentTransactionMessage () -+ (SKPaymentTransactionMessage *)fromList:(NSArray *)list; -+ (nullable SKPaymentTransactionMessage *)nullableFromList:(NSArray *)list; +@interface FIASKPaymentTransactionMessage () ++ (FIASKPaymentTransactionMessage *)fromList:(NSArray *)list; ++ (nullable FIASKPaymentTransactionMessage *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end -@interface SKPaymentMessage () -+ (SKPaymentMessage *)fromList:(NSArray *)list; -+ (nullable SKPaymentMessage *)nullableFromList:(NSArray *)list; +@interface FIASKPaymentMessage () ++ (FIASKPaymentMessage *)fromList:(NSArray *)list; ++ (nullable FIASKPaymentMessage *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end -@interface SKErrorMessage () -+ (SKErrorMessage *)fromList:(NSArray *)list; -+ (nullable SKErrorMessage *)nullableFromList:(NSArray *)list; +@interface FIASKErrorMessage () ++ (FIASKErrorMessage *)fromList:(NSArray *)list; ++ (nullable FIASKErrorMessage *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end -@interface SKPaymentDiscountMessage () -+ (SKPaymentDiscountMessage *)fromList:(NSArray *)list; -+ (nullable SKPaymentDiscountMessage *)nullableFromList:(NSArray *)list; +@interface FIASKPaymentDiscountMessage () ++ (FIASKPaymentDiscountMessage *)fromList:(NSArray *)list; ++ (nullable FIASKPaymentDiscountMessage *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end -@interface SKStorefrontMessage () -+ (SKStorefrontMessage *)fromList:(NSArray *)list; -+ (nullable SKStorefrontMessage *)nullableFromList:(NSArray *)list; +@interface FIASKStorefrontMessage () ++ (FIASKStorefrontMessage *)fromList:(NSArray *)list; ++ (nullable FIASKStorefrontMessage *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end -@interface SKProductsResponseMessage () -+ (SKProductsResponseMessage *)fromList:(NSArray *)list; -+ (nullable SKProductsResponseMessage *)nullableFromList:(NSArray *)list; +@interface FIASKProductsResponseMessage () ++ (FIASKProductsResponseMessage *)fromList:(NSArray *)list; ++ (nullable FIASKProductsResponseMessage *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end -@interface SKProductMessage () -+ (SKProductMessage *)fromList:(NSArray *)list; -+ (nullable SKProductMessage *)nullableFromList:(NSArray *)list; +@interface FIASKProductMessage () ++ (FIASKProductMessage *)fromList:(NSArray *)list; ++ (nullable FIASKProductMessage *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end -@interface SKPriceLocaleMessage () -+ (SKPriceLocaleMessage *)fromList:(NSArray *)list; -+ (nullable SKPriceLocaleMessage *)nullableFromList:(NSArray *)list; +@interface FIASKPriceLocaleMessage () ++ (FIASKPriceLocaleMessage *)fromList:(NSArray *)list; ++ (nullable FIASKPriceLocaleMessage *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end -@interface SKProductDiscountMessage () -+ (SKProductDiscountMessage *)fromList:(NSArray *)list; -+ (nullable SKProductDiscountMessage *)nullableFromList:(NSArray *)list; +@interface FIASKProductDiscountMessage () ++ (FIASKProductDiscountMessage *)fromList:(NSArray *)list; ++ (nullable FIASKProductDiscountMessage *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end -@interface SKProductSubscriptionPeriodMessage () -+ (SKProductSubscriptionPeriodMessage *)fromList:(NSArray *)list; -+ (nullable SKProductSubscriptionPeriodMessage *)nullableFromList:(NSArray *)list; +@interface FIASKProductSubscriptionPeriodMessage () ++ (FIASKProductSubscriptionPeriodMessage *)fromList:(NSArray *)list; ++ (nullable FIASKProductSubscriptionPeriodMessage *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end -@implementation SKPaymentTransactionMessage -+ (instancetype)makeWithPayment:(SKPaymentMessage *)payment - transactionState:(SKPaymentTransactionStateMessage)transactionState - originalTransaction:(nullable SKPaymentTransactionMessage *)originalTransaction +@implementation FIASKPaymentTransactionMessage ++ (instancetype)makeWithPayment:(FIASKPaymentMessage *)payment + transactionState:(FIASKPaymentTransactionStateMessage)transactionState + originalTransaction:(nullable FIASKPaymentTransactionMessage *)originalTransaction transactionTimeStamp:(nullable NSNumber *)transactionTimeStamp transactionIdentifier:(nullable NSString *)transactionIdentifier - error:(nullable SKErrorMessage *)error { - SKPaymentTransactionMessage *pigeonResult = [[SKPaymentTransactionMessage alloc] init]; + error:(nullable FIASKErrorMessage *)error { + FIASKPaymentTransactionMessage *pigeonResult = [[FIASKPaymentTransactionMessage alloc] init]; pigeonResult.payment = payment; pigeonResult.transactionState = transactionState; pigeonResult.originalTransaction = originalTransaction; @@ -146,25 +146,25 @@ + (instancetype)makeWithPayment:(SKPaymentMessage *)payment pigeonResult.error = error; return pigeonResult; } -+ (SKPaymentTransactionMessage *)fromList:(NSArray *)list { - SKPaymentTransactionMessage *pigeonResult = [[SKPaymentTransactionMessage alloc] init]; ++ (FIASKPaymentTransactionMessage *)fromList:(NSArray *)list { + FIASKPaymentTransactionMessage *pigeonResult = [[FIASKPaymentTransactionMessage alloc] init]; pigeonResult.payment = GetNullableObjectAtIndex(list, 0); - SKPaymentTransactionStateMessageBox *boxedSKPaymentTransactionStateMessage = + FIASKPaymentTransactionStateMessageBox *boxedFIASKPaymentTransactionStateMessage = GetNullableObjectAtIndex(list, 1); - pigeonResult.transactionState = boxedSKPaymentTransactionStateMessage.value; + pigeonResult.transactionState = boxedFIASKPaymentTransactionStateMessage.value; pigeonResult.originalTransaction = GetNullableObjectAtIndex(list, 2); pigeonResult.transactionTimeStamp = GetNullableObjectAtIndex(list, 3); pigeonResult.transactionIdentifier = GetNullableObjectAtIndex(list, 4); pigeonResult.error = GetNullableObjectAtIndex(list, 5); return pigeonResult; } -+ (nullable SKPaymentTransactionMessage *)nullableFromList:(NSArray *)list { - return (list) ? [SKPaymentTransactionMessage fromList:list] : nil; ++ (nullable FIASKPaymentTransactionMessage *)nullableFromList:(NSArray *)list { + return (list) ? [FIASKPaymentTransactionMessage fromList:list] : nil; } - (NSArray *)toList { return @[ self.payment ?: [NSNull null], - [[SKPaymentTransactionStateMessageBox alloc] initWithValue:self.transactionState], + [[FIASKPaymentTransactionStateMessageBox alloc] initWithValue:self.transactionState], self.originalTransaction ?: [NSNull null], self.transactionTimeStamp ?: [NSNull null], self.transactionIdentifier ?: [NSNull null], @@ -173,14 +173,14 @@ + (nullable SKPaymentTransactionMessage *)nullableFromList:(NSArray *)list { } @end -@implementation SKPaymentMessage +@implementation FIASKPaymentMessage + (instancetype)makeWithProductIdentifier:(NSString *)productIdentifier applicationUsername:(nullable NSString *)applicationUsername requestData:(nullable NSString *)requestData quantity:(NSInteger)quantity simulatesAskToBuyInSandbox:(BOOL)simulatesAskToBuyInSandbox - paymentDiscount:(nullable SKPaymentDiscountMessage *)paymentDiscount { - SKPaymentMessage *pigeonResult = [[SKPaymentMessage alloc] init]; + paymentDiscount:(nullable FIASKPaymentDiscountMessage *)paymentDiscount { + FIASKPaymentMessage *pigeonResult = [[FIASKPaymentMessage alloc] init]; pigeonResult.productIdentifier = productIdentifier; pigeonResult.applicationUsername = applicationUsername; pigeonResult.requestData = requestData; @@ -189,8 +189,8 @@ + (instancetype)makeWithProductIdentifier:(NSString *)productIdentifier pigeonResult.paymentDiscount = paymentDiscount; return pigeonResult; } -+ (SKPaymentMessage *)fromList:(NSArray *)list { - SKPaymentMessage *pigeonResult = [[SKPaymentMessage alloc] init]; ++ (FIASKPaymentMessage *)fromList:(NSArray *)list { + FIASKPaymentMessage *pigeonResult = [[FIASKPaymentMessage alloc] init]; pigeonResult.productIdentifier = GetNullableObjectAtIndex(list, 0); pigeonResult.applicationUsername = GetNullableObjectAtIndex(list, 1); pigeonResult.requestData = GetNullableObjectAtIndex(list, 2); @@ -199,8 +199,8 @@ + (SKPaymentMessage *)fromList:(NSArray *)list { pigeonResult.paymentDiscount = GetNullableObjectAtIndex(list, 5); return pigeonResult; } -+ (nullable SKPaymentMessage *)nullableFromList:(NSArray *)list { - return (list) ? [SKPaymentMessage fromList:list] : nil; ++ (nullable FIASKPaymentMessage *)nullableFromList:(NSArray *)list { + return (list) ? [FIASKPaymentMessage fromList:list] : nil; } - (NSArray *)toList { return @[ @@ -214,25 +214,25 @@ + (nullable SKPaymentMessage *)nullableFromList:(NSArray *)list { } @end -@implementation SKErrorMessage +@implementation FIASKErrorMessage + (instancetype)makeWithCode:(NSInteger)code domain:(NSString *)domain userInfo:(nullable NSDictionary *)userInfo { - SKErrorMessage *pigeonResult = [[SKErrorMessage alloc] init]; + FIASKErrorMessage *pigeonResult = [[FIASKErrorMessage alloc] init]; pigeonResult.code = code; pigeonResult.domain = domain; pigeonResult.userInfo = userInfo; return pigeonResult; } -+ (SKErrorMessage *)fromList:(NSArray *)list { - SKErrorMessage *pigeonResult = [[SKErrorMessage alloc] init]; ++ (FIASKErrorMessage *)fromList:(NSArray *)list { + FIASKErrorMessage *pigeonResult = [[FIASKErrorMessage alloc] init]; pigeonResult.code = [GetNullableObjectAtIndex(list, 0) integerValue]; pigeonResult.domain = GetNullableObjectAtIndex(list, 1); pigeonResult.userInfo = GetNullableObjectAtIndex(list, 2); return pigeonResult; } -+ (nullable SKErrorMessage *)nullableFromList:(NSArray *)list { - return (list) ? [SKErrorMessage fromList:list] : nil; ++ (nullable FIASKErrorMessage *)nullableFromList:(NSArray *)list { + return (list) ? [FIASKErrorMessage fromList:list] : nil; } - (NSArray *)toList { return @[ @@ -243,13 +243,13 @@ + (nullable SKErrorMessage *)nullableFromList:(NSArray *)list { } @end -@implementation SKPaymentDiscountMessage +@implementation FIASKPaymentDiscountMessage + (instancetype)makeWithIdentifier:(NSString *)identifier keyIdentifier:(NSString *)keyIdentifier nonce:(NSString *)nonce signature:(NSString *)signature timestamp:(NSInteger)timestamp { - SKPaymentDiscountMessage *pigeonResult = [[SKPaymentDiscountMessage alloc] init]; + FIASKPaymentDiscountMessage *pigeonResult = [[FIASKPaymentDiscountMessage alloc] init]; pigeonResult.identifier = identifier; pigeonResult.keyIdentifier = keyIdentifier; pigeonResult.nonce = nonce; @@ -257,8 +257,8 @@ + (instancetype)makeWithIdentifier:(NSString *)identifier pigeonResult.timestamp = timestamp; return pigeonResult; } -+ (SKPaymentDiscountMessage *)fromList:(NSArray *)list { - SKPaymentDiscountMessage *pigeonResult = [[SKPaymentDiscountMessage alloc] init]; ++ (FIASKPaymentDiscountMessage *)fromList:(NSArray *)list { + FIASKPaymentDiscountMessage *pigeonResult = [[FIASKPaymentDiscountMessage alloc] init]; pigeonResult.identifier = GetNullableObjectAtIndex(list, 0); pigeonResult.keyIdentifier = GetNullableObjectAtIndex(list, 1); pigeonResult.nonce = GetNullableObjectAtIndex(list, 2); @@ -266,8 +266,8 @@ + (SKPaymentDiscountMessage *)fromList:(NSArray *)list { pigeonResult.timestamp = [GetNullableObjectAtIndex(list, 4) integerValue]; return pigeonResult; } -+ (nullable SKPaymentDiscountMessage *)nullableFromList:(NSArray *)list { - return (list) ? [SKPaymentDiscountMessage fromList:list] : nil; ++ (nullable FIASKPaymentDiscountMessage *)nullableFromList:(NSArray *)list { + return (list) ? [FIASKPaymentDiscountMessage fromList:list] : nil; } - (NSArray *)toList { return @[ @@ -280,21 +280,21 @@ + (nullable SKPaymentDiscountMessage *)nullableFromList:(NSArray *)list { } @end -@implementation SKStorefrontMessage +@implementation FIASKStorefrontMessage + (instancetype)makeWithCountryCode:(NSString *)countryCode identifier:(NSString *)identifier { - SKStorefrontMessage *pigeonResult = [[SKStorefrontMessage alloc] init]; + FIASKStorefrontMessage *pigeonResult = [[FIASKStorefrontMessage alloc] init]; pigeonResult.countryCode = countryCode; pigeonResult.identifier = identifier; return pigeonResult; } -+ (SKStorefrontMessage *)fromList:(NSArray *)list { - SKStorefrontMessage *pigeonResult = [[SKStorefrontMessage alloc] init]; ++ (FIASKStorefrontMessage *)fromList:(NSArray *)list { + FIASKStorefrontMessage *pigeonResult = [[FIASKStorefrontMessage alloc] init]; pigeonResult.countryCode = GetNullableObjectAtIndex(list, 0); pigeonResult.identifier = GetNullableObjectAtIndex(list, 1); return pigeonResult; } -+ (nullable SKStorefrontMessage *)nullableFromList:(NSArray *)list { - return (list) ? [SKStorefrontMessage fromList:list] : nil; ++ (nullable FIASKStorefrontMessage *)nullableFromList:(NSArray *)list { + return (list) ? [FIASKStorefrontMessage fromList:list] : nil; } - (NSArray *)toList { return @[ @@ -304,22 +304,22 @@ + (nullable SKStorefrontMessage *)nullableFromList:(NSArray *)list { } @end -@implementation SKProductsResponseMessage -+ (instancetype)makeWithProducts:(nullable NSArray *)products +@implementation FIASKProductsResponseMessage ++ (instancetype)makeWithProducts:(nullable NSArray *)products invalidProductIdentifiers:(nullable NSArray *)invalidProductIdentifiers { - SKProductsResponseMessage *pigeonResult = [[SKProductsResponseMessage alloc] init]; + FIASKProductsResponseMessage *pigeonResult = [[FIASKProductsResponseMessage alloc] init]; pigeonResult.products = products; pigeonResult.invalidProductIdentifiers = invalidProductIdentifiers; return pigeonResult; } -+ (SKProductsResponseMessage *)fromList:(NSArray *)list { - SKProductsResponseMessage *pigeonResult = [[SKProductsResponseMessage alloc] init]; ++ (FIASKProductsResponseMessage *)fromList:(NSArray *)list { + FIASKProductsResponseMessage *pigeonResult = [[FIASKProductsResponseMessage alloc] init]; pigeonResult.products = GetNullableObjectAtIndex(list, 0); pigeonResult.invalidProductIdentifiers = GetNullableObjectAtIndex(list, 1); return pigeonResult; } -+ (nullable SKProductsResponseMessage *)nullableFromList:(NSArray *)list { - return (list) ? [SKProductsResponseMessage fromList:list] : nil; ++ (nullable FIASKProductsResponseMessage *)nullableFromList:(NSArray *)list { + return (list) ? [FIASKProductsResponseMessage fromList:list] : nil; } - (NSArray *)toList { return @[ @@ -329,18 +329,18 @@ + (nullable SKProductsResponseMessage *)nullableFromList:(NSArray *)list { } @end -@implementation SKProductMessage +@implementation FIASKProductMessage + (instancetype) makeWithProductIdentifier:(NSString *)productIdentifier localizedTitle:(NSString *)localizedTitle localizedDescription:(nullable NSString *)localizedDescription - priceLocale:(SKPriceLocaleMessage *)priceLocale + priceLocale:(FIASKPriceLocaleMessage *)priceLocale subscriptionGroupIdentifier:(nullable NSString *)subscriptionGroupIdentifier price:(NSString *)price - subscriptionPeriod:(nullable SKProductSubscriptionPeriodMessage *)subscriptionPeriod - introductoryPrice:(nullable SKProductDiscountMessage *)introductoryPrice - discounts:(nullable NSArray *)discounts { - SKProductMessage *pigeonResult = [[SKProductMessage alloc] init]; + 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; @@ -352,8 +352,8 @@ @implementation SKProductMessage pigeonResult.discounts = discounts; return pigeonResult; } -+ (SKProductMessage *)fromList:(NSArray *)list { - SKProductMessage *pigeonResult = [[SKProductMessage alloc] init]; ++ (FIASKProductMessage *)fromList:(NSArray *)list { + FIASKProductMessage *pigeonResult = [[FIASKProductMessage alloc] init]; pigeonResult.productIdentifier = GetNullableObjectAtIndex(list, 0); pigeonResult.localizedTitle = GetNullableObjectAtIndex(list, 1); pigeonResult.localizedDescription = GetNullableObjectAtIndex(list, 2); @@ -365,8 +365,8 @@ + (SKProductMessage *)fromList:(NSArray *)list { pigeonResult.discounts = GetNullableObjectAtIndex(list, 8); return pigeonResult; } -+ (nullable SKProductMessage *)nullableFromList:(NSArray *)list { - return (list) ? [SKProductMessage fromList:list] : nil; ++ (nullable FIASKProductMessage *)nullableFromList:(NSArray *)list { + return (list) ? [FIASKProductMessage fromList:list] : nil; } - (NSArray *)toList { return @[ @@ -383,25 +383,25 @@ + (nullable SKProductMessage *)nullableFromList:(NSArray *)list { } @end -@implementation SKPriceLocaleMessage +@implementation FIASKPriceLocaleMessage + (instancetype)makeWithCurrencySymbol:(NSString *)currencySymbol currencyCode:(NSString *)currencyCode countryCode:(NSString *)countryCode { - SKPriceLocaleMessage *pigeonResult = [[SKPriceLocaleMessage alloc] init]; + FIASKPriceLocaleMessage *pigeonResult = [[FIASKPriceLocaleMessage alloc] init]; pigeonResult.currencySymbol = currencySymbol; pigeonResult.currencyCode = currencyCode; pigeonResult.countryCode = countryCode; return pigeonResult; } -+ (SKPriceLocaleMessage *)fromList:(NSArray *)list { - SKPriceLocaleMessage *pigeonResult = [[SKPriceLocaleMessage alloc] init]; ++ (FIASKPriceLocaleMessage *)fromList:(NSArray *)list { + FIASKPriceLocaleMessage *pigeonResult = [[FIASKPriceLocaleMessage alloc] init]; pigeonResult.currencySymbol = GetNullableObjectAtIndex(list, 0); pigeonResult.currencyCode = GetNullableObjectAtIndex(list, 1); pigeonResult.countryCode = GetNullableObjectAtIndex(list, 2); return pigeonResult; } -+ (nullable SKPriceLocaleMessage *)nullableFromList:(NSArray *)list { - return (list) ? [SKPriceLocaleMessage fromList:list] : nil; ++ (nullable FIASKPriceLocaleMessage *)nullableFromList:(NSArray *)list { + return (list) ? [FIASKPriceLocaleMessage fromList:list] : nil; } - (NSArray *)toList { return @[ @@ -412,15 +412,15 @@ + (nullable SKPriceLocaleMessage *)nullableFromList:(NSArray *)list { } @end -@implementation SKProductDiscountMessage +@implementation FIASKProductDiscountMessage + (instancetype)makeWithPrice:(NSString *)price - priceLocale:(SKPriceLocaleMessage *)priceLocale + priceLocale:(FIASKPriceLocaleMessage *)priceLocale numberOfPeriods:(NSInteger)numberOfPeriods - paymentMode:(SKProductDiscountPaymentModeMessage)paymentMode - subscriptionPeriod:(SKProductSubscriptionPeriodMessage *)subscriptionPeriod + paymentMode:(FIASKProductDiscountPaymentModeMessage)paymentMode + subscriptionPeriod:(FIASKProductSubscriptionPeriodMessage *)subscriptionPeriod identifier:(nullable NSString *)identifier - type:(SKProductDiscountTypeMessage)type { - SKProductDiscountMessage *pigeonResult = [[SKProductDiscountMessage alloc] init]; + type:(FIASKProductDiscountTypeMessage)type { + FIASKProductDiscountMessage *pigeonResult = [[FIASKProductDiscountMessage alloc] init]; pigeonResult.price = price; pigeonResult.priceLocale = priceLocale; pigeonResult.numberOfPeriods = numberOfPeriods; @@ -430,169 +430,170 @@ + (instancetype)makeWithPrice:(NSString *)price pigeonResult.type = type; return pigeonResult; } -+ (SKProductDiscountMessage *)fromList:(NSArray *)list { - SKProductDiscountMessage *pigeonResult = [[SKProductDiscountMessage alloc] init]; ++ (FIASKProductDiscountMessage *)fromList:(NSArray *)list { + FIASKProductDiscountMessage *pigeonResult = [[FIASKProductDiscountMessage alloc] init]; pigeonResult.price = GetNullableObjectAtIndex(list, 0); pigeonResult.priceLocale = GetNullableObjectAtIndex(list, 1); pigeonResult.numberOfPeriods = [GetNullableObjectAtIndex(list, 2) integerValue]; - SKProductDiscountPaymentModeMessageBox *boxedSKProductDiscountPaymentModeMessage = + FIASKProductDiscountPaymentModeMessageBox *boxedFIASKProductDiscountPaymentModeMessage = GetNullableObjectAtIndex(list, 3); - pigeonResult.paymentMode = boxedSKProductDiscountPaymentModeMessage.value; + pigeonResult.paymentMode = boxedFIASKProductDiscountPaymentModeMessage.value; pigeonResult.subscriptionPeriod = GetNullableObjectAtIndex(list, 4); pigeonResult.identifier = GetNullableObjectAtIndex(list, 5); - SKProductDiscountTypeMessageBox *boxedSKProductDiscountTypeMessage = + FIASKProductDiscountTypeMessageBox *boxedFIASKProductDiscountTypeMessage = GetNullableObjectAtIndex(list, 6); - pigeonResult.type = boxedSKProductDiscountTypeMessage.value; + pigeonResult.type = boxedFIASKProductDiscountTypeMessage.value; return pigeonResult; } -+ (nullable SKProductDiscountMessage *)nullableFromList:(NSArray *)list { - return (list) ? [SKProductDiscountMessage fromList:list] : nil; ++ (nullable FIASKProductDiscountMessage *)nullableFromList:(NSArray *)list { + return (list) ? [FIASKProductDiscountMessage fromList:list] : nil; } - (NSArray *)toList { return @[ self.price ?: [NSNull null], self.priceLocale ?: [NSNull null], @(self.numberOfPeriods), - [[SKProductDiscountPaymentModeMessageBox alloc] initWithValue:self.paymentMode], + [[FIASKProductDiscountPaymentModeMessageBox alloc] initWithValue:self.paymentMode], self.subscriptionPeriod ?: [NSNull null], self.identifier ?: [NSNull null], - [[SKProductDiscountTypeMessageBox alloc] initWithValue:self.type], + [[FIASKProductDiscountTypeMessageBox alloc] initWithValue:self.type], ]; } @end -@implementation SKProductSubscriptionPeriodMessage +@implementation FIASKProductSubscriptionPeriodMessage + (instancetype)makeWithNumberOfUnits:(NSInteger)numberOfUnits - unit:(SKSubscriptionPeriodUnitMessage)unit { - SKProductSubscriptionPeriodMessage *pigeonResult = - [[SKProductSubscriptionPeriodMessage alloc] init]; + unit:(FIASKSubscriptionPeriodUnitMessage)unit { + FIASKProductSubscriptionPeriodMessage *pigeonResult = + [[FIASKProductSubscriptionPeriodMessage alloc] init]; pigeonResult.numberOfUnits = numberOfUnits; pigeonResult.unit = unit; return pigeonResult; } -+ (SKProductSubscriptionPeriodMessage *)fromList:(NSArray *)list { - SKProductSubscriptionPeriodMessage *pigeonResult = - [[SKProductSubscriptionPeriodMessage alloc] init]; ++ (FIASKProductSubscriptionPeriodMessage *)fromList:(NSArray *)list { + FIASKProductSubscriptionPeriodMessage *pigeonResult = + [[FIASKProductSubscriptionPeriodMessage alloc] init]; pigeonResult.numberOfUnits = [GetNullableObjectAtIndex(list, 0) integerValue]; - SKSubscriptionPeriodUnitMessageBox *boxedSKSubscriptionPeriodUnitMessage = + FIASKSubscriptionPeriodUnitMessageBox *boxedFIASKSubscriptionPeriodUnitMessage = GetNullableObjectAtIndex(list, 1); - pigeonResult.unit = boxedSKSubscriptionPeriodUnitMessage.value; + pigeonResult.unit = boxedFIASKSubscriptionPeriodUnitMessage.value; return pigeonResult; } -+ (nullable SKProductSubscriptionPeriodMessage *)nullableFromList:(NSArray *)list { - return (list) ? [SKProductSubscriptionPeriodMessage fromList:list] : nil; ++ (nullable FIASKProductSubscriptionPeriodMessage *)nullableFromList:(NSArray *)list { + return (list) ? [FIASKProductSubscriptionPeriodMessage fromList:list] : nil; } - (NSArray *)toList { return @[ @(self.numberOfUnits), - [[SKSubscriptionPeriodUnitMessageBox alloc] initWithValue:self.unit], + [[FIASKSubscriptionPeriodUnitMessageBox alloc] initWithValue:self.unit], ]; } @end -@interface nullMessagesPigeonCodecReader : FlutterStandardReader +@interface FIAMessagesPigeonCodecReader : FlutterStandardReader @end -@implementation nullMessagesPigeonCodecReader +@implementation FIAMessagesPigeonCodecReader - (nullable id)readValueOfType:(UInt8)type { switch (type) { case 129: { NSNumber *enumAsNumber = [self readValue]; return enumAsNumber == nil ? nil - : [[SKPaymentTransactionStateMessageBox alloc] + : [[FIASKPaymentTransactionStateMessageBox alloc] initWithValue:[enumAsNumber integerValue]]; } case 130: { NSNumber *enumAsNumber = [self readValue]; return enumAsNumber == nil ? nil - : [[SKProductDiscountTypeMessageBox alloc] + : [[FIASKProductDiscountTypeMessageBox alloc] initWithValue:[enumAsNumber integerValue]]; } case 131: { NSNumber *enumAsNumber = [self readValue]; return enumAsNumber == nil ? nil - : [[SKProductDiscountPaymentModeMessageBox alloc] + : [[FIASKProductDiscountPaymentModeMessageBox alloc] initWithValue:[enumAsNumber integerValue]]; } case 132: { NSNumber *enumAsNumber = [self readValue]; return enumAsNumber == nil ? nil - : [[SKSubscriptionPeriodUnitMessageBox alloc] + : [[FIASKSubscriptionPeriodUnitMessageBox alloc] initWithValue:[enumAsNumber integerValue]]; } case 133: - return [SKPaymentTransactionMessage fromList:[self readValue]]; + return [FIASKPaymentTransactionMessage fromList:[self readValue]]; case 134: - return [SKPaymentMessage fromList:[self readValue]]; + return [FIASKPaymentMessage fromList:[self readValue]]; case 135: - return [SKErrorMessage fromList:[self readValue]]; + return [FIASKErrorMessage fromList:[self readValue]]; case 136: - return [SKPaymentDiscountMessage fromList:[self readValue]]; + return [FIASKPaymentDiscountMessage fromList:[self readValue]]; case 137: - return [SKStorefrontMessage fromList:[self readValue]]; + return [FIASKStorefrontMessage fromList:[self readValue]]; case 138: - return [SKProductsResponseMessage fromList:[self readValue]]; + return [FIASKProductsResponseMessage fromList:[self readValue]]; case 139: - return [SKProductMessage fromList:[self readValue]]; + return [FIASKProductMessage fromList:[self readValue]]; case 140: - return [SKPriceLocaleMessage fromList:[self readValue]]; + return [FIASKPriceLocaleMessage fromList:[self readValue]]; case 141: - return [SKProductDiscountMessage fromList:[self readValue]]; + return [FIASKProductDiscountMessage fromList:[self readValue]]; case 142: - return [SKProductSubscriptionPeriodMessage fromList:[self readValue]]; + return [FIASKProductSubscriptionPeriodMessage fromList:[self readValue]]; default: return [super readValueOfType:type]; } } @end -@interface nullMessagesPigeonCodecWriter : FlutterStandardWriter +@interface FIAMessagesPigeonCodecWriter : FlutterStandardWriter @end -@implementation nullMessagesPigeonCodecWriter +@implementation FIAMessagesPigeonCodecWriter - (void)writeValue:(id)value { - if ([value isKindOfClass:[SKPaymentTransactionStateMessageBox class]]) { - SKPaymentTransactionStateMessageBox *box = (SKPaymentTransactionStateMessageBox *)value; + if ([value isKindOfClass:[FIASKPaymentTransactionStateMessageBox class]]) { + FIASKPaymentTransactionStateMessageBox *box = (FIASKPaymentTransactionStateMessageBox *)value; [self writeByte:129]; [self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])]; - } else if ([value isKindOfClass:[SKProductDiscountTypeMessageBox class]]) { - SKProductDiscountTypeMessageBox *box = (SKProductDiscountTypeMessageBox *)value; + } else if ([value isKindOfClass:[FIASKProductDiscountTypeMessageBox class]]) { + FIASKProductDiscountTypeMessageBox *box = (FIASKProductDiscountTypeMessageBox *)value; [self writeByte:130]; [self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])]; - } else if ([value isKindOfClass:[SKProductDiscountPaymentModeMessageBox class]]) { - SKProductDiscountPaymentModeMessageBox *box = (SKProductDiscountPaymentModeMessageBox *)value; + } else if ([value isKindOfClass:[FIASKProductDiscountPaymentModeMessageBox class]]) { + FIASKProductDiscountPaymentModeMessageBox *box = + (FIASKProductDiscountPaymentModeMessageBox *)value; [self writeByte:131]; [self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])]; - } else if ([value isKindOfClass:[SKSubscriptionPeriodUnitMessageBox class]]) { - SKSubscriptionPeriodUnitMessageBox *box = (SKSubscriptionPeriodUnitMessageBox *)value; + } else if ([value isKindOfClass:[FIASKSubscriptionPeriodUnitMessageBox class]]) { + FIASKSubscriptionPeriodUnitMessageBox *box = (FIASKSubscriptionPeriodUnitMessageBox *)value; [self writeByte:132]; [self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])]; - } else if ([value isKindOfClass:[SKPaymentTransactionMessage class]]) { + } else if ([value isKindOfClass:[FIASKPaymentTransactionMessage class]]) { [self writeByte:133]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[SKPaymentMessage class]]) { + } else if ([value isKindOfClass:[FIASKPaymentMessage class]]) { [self writeByte:134]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[SKErrorMessage class]]) { + } else if ([value isKindOfClass:[FIASKErrorMessage class]]) { [self writeByte:135]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[SKPaymentDiscountMessage class]]) { + } else if ([value isKindOfClass:[FIASKPaymentDiscountMessage class]]) { [self writeByte:136]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[SKStorefrontMessage class]]) { + } else if ([value isKindOfClass:[FIASKStorefrontMessage class]]) { [self writeByte:137]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[SKProductsResponseMessage class]]) { + } else if ([value isKindOfClass:[FIASKProductsResponseMessage class]]) { [self writeByte:138]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[SKProductMessage class]]) { + } else if ([value isKindOfClass:[FIASKProductMessage class]]) { [self writeByte:139]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[SKPriceLocaleMessage class]]) { + } else if ([value isKindOfClass:[FIASKPriceLocaleMessage class]]) { [self writeByte:140]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[SKProductDiscountMessage class]]) { + } else if ([value isKindOfClass:[FIASKProductDiscountMessage class]]) { [self writeByte:141]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[SKProductSubscriptionPeriodMessage class]]) { + } else if ([value isKindOfClass:[FIASKProductSubscriptionPeriodMessage class]]) { [self writeByte:142]; [self writeValue:[value toList]]; } else { @@ -601,35 +602,35 @@ - (void)writeValue:(id)value { } @end -@interface nullMessagesPigeonCodecReaderWriter : FlutterStandardReaderWriter +@interface FIAMessagesPigeonCodecReaderWriter : FlutterStandardReaderWriter @end -@implementation nullMessagesPigeonCodecReaderWriter +@implementation FIAMessagesPigeonCodecReaderWriter - (FlutterStandardWriter *)writerWithData:(NSMutableData *)data { - return [[nullMessagesPigeonCodecWriter alloc] initWithData:data]; + return [[FIAMessagesPigeonCodecWriter alloc] initWithData:data]; } - (FlutterStandardReader *)readerWithData:(NSData *)data { - return [[nullMessagesPigeonCodecReader alloc] initWithData:data]; + return [[FIAMessagesPigeonCodecReader alloc] initWithData:data]; } @end -NSObject *nullGetMessagesCodec(void) { +NSObject *FIAGetMessagesCodec(void) { static FlutterStandardMessageCodec *sSharedObject = nil; static dispatch_once_t sPred = 0; dispatch_once(&sPred, ^{ - nullMessagesPigeonCodecReaderWriter *readerWriter = - [[nullMessagesPigeonCodecReaderWriter alloc] init]; + FIAMessagesPigeonCodecReaderWriter *readerWriter = + [[FIAMessagesPigeonCodecReaderWriter alloc] init]; sSharedObject = [FlutterStandardMessageCodec codecWithReaderWriter:readerWriter]; }); return sSharedObject; } -void SetUpInAppPurchaseAPI(id binaryMessenger, - NSObject *api) { - SetUpInAppPurchaseAPIWithSuffix(binaryMessenger, api, @""); +void SetUpFIAInAppPurchaseAPI(id binaryMessenger, + NSObject *api) { + SetUpFIAInAppPurchaseAPIWithSuffix(binaryMessenger, api, @""); } -void SetUpInAppPurchaseAPIWithSuffix(id binaryMessenger, - NSObject *api, - NSString *messageChannelSuffix) { +void SetUpFIAInAppPurchaseAPIWithSuffix(id binaryMessenger, + NSObject *api, + NSString *messageChannelSuffix) { messageChannelSuffix = messageChannelSuffix.length > 0 ? [NSString stringWithFormat:@".%@", messageChannelSuffix] : @""; @@ -641,11 +642,11 @@ void SetUpInAppPurchaseAPIWithSuffix(id binaryMessenger, @"InAppPurchaseAPI.canMakePayments", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:nullGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { NSCAssert( [api respondsToSelector:@selector(canMakePaymentsWithError:)], - @"InAppPurchaseAPI api (%@) doesn't respond to @selector(canMakePaymentsWithError:)", + @"FIAInAppPurchaseAPI api (%@) doesn't respond to @selector(canMakePaymentsWithError:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { FlutterError *error; @@ -663,14 +664,15 @@ void SetUpInAppPurchaseAPIWithSuffix(id binaryMessenger, @"InAppPurchaseAPI.transactions", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:nullGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { - NSCAssert([api respondsToSelector:@selector(transactionsWithError:)], - @"InAppPurchaseAPI 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]; + NSArray *output = [api transactionsWithError:&error]; callback(wrapResult(output, error)); }]; } else { @@ -684,14 +686,14 @@ void SetUpInAppPurchaseAPIWithSuffix(id binaryMessenger, @"InAppPurchaseAPI.storefront", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:nullGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(storefrontWithError:)], - @"InAppPurchaseAPI api (%@) doesn't respond to @selector(storefrontWithError:)", + @"FIAInAppPurchaseAPI api (%@) doesn't respond to @selector(storefrontWithError:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { FlutterError *error; - SKStorefrontMessage *output = [api storefrontWithError:&error]; + FIASKStorefrontMessage *output = [api storefrontWithError:&error]; callback(wrapResult(output, error)); }]; } else { @@ -705,11 +707,11 @@ void SetUpInAppPurchaseAPIWithSuffix(id binaryMessenger, @"InAppPurchaseAPI.addPayment", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:nullGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { NSCAssert( [api respondsToSelector:@selector(addPaymentPaymentMap:error:)], - @"InAppPurchaseAPI api (%@) doesn't respond to @selector(addPaymentPaymentMap:error:)", + @"FIAInAppPurchaseAPI api (%@) doesn't respond to @selector(addPaymentPaymentMap:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; @@ -729,18 +731,18 @@ void SetUpInAppPurchaseAPIWithSuffix(id binaryMessenger, @"InAppPurchaseAPI.startProductRequest", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:nullGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(startProductRequestProductIdentifiers: completion:)], - @"InAppPurchaseAPI api (%@) doesn't respond to " + @"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:^(SKProductsResponseMessage *_Nullable output, + completion:^(FIASKProductsResponseMessage *_Nullable output, FlutterError *_Nullable error) { callback(wrapResult(output, error)); }]; @@ -756,10 +758,10 @@ void SetUpInAppPurchaseAPIWithSuffix(id binaryMessenger, @"InAppPurchaseAPI.finishTransaction", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:nullGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(finishTransactionFinishMap:error:)], - @"InAppPurchaseAPI api (%@) doesn't respond to " + @"FIAInAppPurchaseAPI api (%@) doesn't respond to " @"@selector(finishTransactionFinishMap:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -780,10 +782,10 @@ void SetUpInAppPurchaseAPIWithSuffix(id binaryMessenger, @"InAppPurchaseAPI.restoreTransactions", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:nullGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(restoreTransactionsApplicationUserName:error:)], - @"InAppPurchaseAPI api (%@) doesn't respond to " + @"FIAInAppPurchaseAPI api (%@) doesn't respond to " @"@selector(restoreTransactionsApplicationUserName:error:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -804,10 +806,10 @@ void SetUpInAppPurchaseAPIWithSuffix(id binaryMessenger, @"InAppPurchaseAPI.presentCodeRedemptionSheet", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:nullGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(presentCodeRedemptionSheetWithError:)], - @"InAppPurchaseAPI api (%@) doesn't respond to " + @"FIAInAppPurchaseAPI api (%@) doesn't respond to " @"@selector(presentCodeRedemptionSheetWithError:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -826,12 +828,12 @@ void SetUpInAppPurchaseAPIWithSuffix(id binaryMessenger, @"InAppPurchaseAPI.retrieveReceiptData", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:nullGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { - NSCAssert( - [api respondsToSelector:@selector(retrieveReceiptDataWithError:)], - @"InAppPurchaseAPI 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]; @@ -848,10 +850,10 @@ void SetUpInAppPurchaseAPIWithSuffix(id binaryMessenger, @"InAppPurchaseAPI.refreshReceipt", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:nullGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(refreshReceiptReceiptProperties:completion:)], - @"InAppPurchaseAPI api (%@) doesn't respond to " + @"FIAInAppPurchaseAPI api (%@) doesn't respond to " @"@selector(refreshReceiptReceiptProperties:completion:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -873,10 +875,10 @@ void SetUpInAppPurchaseAPIWithSuffix(id binaryMessenger, @"InAppPurchaseAPI.startObservingPaymentQueue", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:nullGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(startObservingPaymentQueueWithError:)], - @"InAppPurchaseAPI api (%@) doesn't respond to " + @"FIAInAppPurchaseAPI api (%@) doesn't respond to " @"@selector(startObservingPaymentQueueWithError:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -895,10 +897,10 @@ void SetUpInAppPurchaseAPIWithSuffix(id binaryMessenger, @"InAppPurchaseAPI.stopObservingPaymentQueue", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:nullGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(stopObservingPaymentQueueWithError:)], - @"InAppPurchaseAPI api (%@) doesn't respond to " + @"FIAInAppPurchaseAPI api (%@) doesn't respond to " @"@selector(stopObservingPaymentQueueWithError:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -917,10 +919,10 @@ void SetUpInAppPurchaseAPIWithSuffix(id binaryMessenger, @"InAppPurchaseAPI.registerPaymentQueueDelegate", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:nullGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(registerPaymentQueueDelegateWithError:)], - @"InAppPurchaseAPI api (%@) doesn't respond to " + @"FIAInAppPurchaseAPI api (%@) doesn't respond to " @"@selector(registerPaymentQueueDelegateWithError:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -939,10 +941,10 @@ void SetUpInAppPurchaseAPIWithSuffix(id binaryMessenger, @"InAppPurchaseAPI.removePaymentQueueDelegate", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:nullGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(removePaymentQueueDelegateWithError:)], - @"InAppPurchaseAPI api (%@) doesn't respond to " + @"FIAInAppPurchaseAPI api (%@) doesn't respond to " @"@selector(removePaymentQueueDelegateWithError:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { @@ -961,10 +963,10 @@ void SetUpInAppPurchaseAPIWithSuffix(id binaryMessenger, @"InAppPurchaseAPI.showPriceConsentIfNeeded", messageChannelSuffix] binaryMessenger:binaryMessenger - codec:nullGetMessagesCodec()]; + codec:FIAGetMessagesCodec()]; if (api) { NSCAssert([api respondsToSelector:@selector(showPriceConsentIfNeededWithError:)], - @"InAppPurchaseAPI api (%@) doesn't respond to " + @"FIAInAppPurchaseAPI api (%@) doesn't respond to " @"@selector(showPriceConsentIfNeededWithError:)", api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { 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 63a1accfe4d..cd7b6b70a57 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 @@ -9,6 +9,9 @@ import 'package:pigeon/pigeon.dart'; dartTestOut: 'test/test_api.g.dart', objcHeaderOut: 'darwin/Classes/messages.g.h', objcSourceOut: 'darwin/Classes/messages.g.m', + objcOptions: ObjcOptions( + prefix: 'FIA', + ), copyrightHeader: 'pigeons/copyright.txt', )) class SKPaymentTransactionMessage { From 0277d32109f75a11d05528ebd66dbd0d1ff140af Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 8 Oct 2024 12:45:43 -0400 Subject: [PATCH 06/10] Update types for prefix --- .../darwin/Classes/FIAObjectTranslator.h | 20 +-- .../darwin/Classes/FIAObjectTranslator.m | 114 ++++++++---------- .../darwin/Classes/InAppPurchasePlugin.swift | 10 +- 3 files changed, 63 insertions(+), 81 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/FIAObjectTranslator.h b/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/FIAObjectTranslator.h index ffb0f1fe958..bca07a58653 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/FIAObjectTranslator.h +++ b/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/FIAObjectTranslator.h @@ -57,33 +57,33 @@ NS_ASSUME_NONNULL_BEGIN withError:(NSString *_Nullable *_Nullable)error API_AVAILABLE(ios(12.2)); -+ (nullable SKPaymentTransactionMessage *)convertTransactionToPigeon: ++ (nullable FIASKPaymentTransactionMessage *)convertTransactionToPigeon: (nullable SKPaymentTransaction *)transaction; -+ (nullable SKStorefrontMessage *)convertStorefrontToPigeon:(nullable SKStorefront *)storefront ++ (nullable FIASKStorefrontMessage *)convertStorefrontToPigeon:(nullable SKStorefront *)storefront API_AVAILABLE(ios(13.0)); -+ (nullable SKPaymentDiscountMessage *)convertPaymentDiscountToPigeon: ++ (nullable FIASKPaymentDiscountMessage *)convertPaymentDiscountToPigeon: (nullable SKPaymentDiscount *)discount API_AVAILABLE(ios(12.2)); -+ (nullable SKPaymentMessage *)convertPaymentToPigeon:(nullable SKPayment *)payment ++ (nullable FIASKPaymentMessage *)convertPaymentToPigeon:(nullable SKPayment *)payment API_AVAILABLE(ios(12.2)); -+ (nullable SKErrorMessage *)convertSKErrorToPigeon:(nullable NSError *)error; ++ (nullable FIASKErrorMessage *)convertSKErrorToPigeon:(nullable NSError *)error; -+ (nullable SKProductsResponseMessage *)convertProductsResponseToPigeon: ++ (nullable FIASKProductsResponseMessage *)convertProductsResponseToPigeon: (nullable SKProductsResponse *)payment; -+ (nullable SKProductMessage *)convertProductToPigeon:(nullable SKProduct *)product ++ (nullable FIASKProductMessage *)convertProductToPigeon:(nullable SKProduct *)product API_AVAILABLE(ios(12.2)); -+ (nullable SKProductDiscountMessage *)convertProductDiscountToPigeon: ++ (nullable FIASKProductDiscountMessage *)convertProductDiscountToPigeon: (nullable SKProductDiscount *)productDiscount API_AVAILABLE(ios(12.2)); -+ (nullable SKPriceLocaleMessage *)convertNSLocaleToPigeon:(nullable NSLocale *)locale ++ (nullable FIASKPriceLocaleMessage *)convertNSLocaleToPigeon:(nullable NSLocale *)locale API_AVAILABLE(ios(12.2)); -+ (nullable SKProductSubscriptionPeriodMessage *)convertSKProductSubscriptionPeriodToPigeon: ++ (nullable FIASKProductSubscriptionPeriodMessage *)convertSKProductSubscriptionPeriodToPigeon: (nullable SKProductSubscriptionPeriod *)period API_AVAILABLE(ios(12.2)); @end diff --git a/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/FIAObjectTranslator.m b/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/FIAObjectTranslator.m index bf05976534b..04f9817250b 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/FIAObjectTranslator.m +++ b/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/FIAObjectTranslator.m @@ -291,12 +291,12 @@ + (SKPaymentDiscount *)getSKPaymentDiscountFromMap:(NSDictionary *)map return discount; } -+ (nullable SKPaymentTransactionMessage *)convertTransactionToPigeon: ++ (nullable FIASKPaymentTransactionMessage *)convertTransactionToPigeon: (nullable SKPaymentTransaction *)transaction API_AVAILABLE(ios(12.2)) { if (!transaction) { return nil; } - SKPaymentTransactionMessage *msg = [SKPaymentTransactionMessage + return [FIASKPaymentTransactionMessage makeWithPayment:[self convertPaymentToPigeon:transaction.payment] transactionState:[self convertTransactionStateToPigeon:transaction.transactionState] originalTransaction:transaction.originalTransaction @@ -306,10 +306,9 @@ + (nullable SKPaymentTransactionMessage *)convertTransactionToPigeon: timeIntervalSince1970]] transactionIdentifier:transaction.transactionIdentifier error:[self convertSKErrorToPigeon:transaction.error]]; - return msg; } -+ (nullable SKErrorMessage *)convertSKErrorToPigeon:(nullable NSError *)error { ++ (nullable FIASKErrorMessage *)convertSKErrorToPigeon:(nullable NSError *)error { if (!error) { return nil; } @@ -320,34 +319,31 @@ + (nullable SKErrorMessage *)convertSKErrorToPigeon:(nullable NSError *)error { userInfo[key] = [FIAObjectTranslator encodeNSErrorUserInfo:value]; } - SKErrorMessage *msg = [SKErrorMessage makeWithCode:error.code - domain:error.domain - userInfo:userInfo]; - return msg; + return [FIASKErrorMessage makeWithCode:error.code domain:error.domain userInfo:userInfo]; } -+ (SKPaymentTransactionStateMessage)convertTransactionStateToPigeon: ++ (FIASKPaymentTransactionStateMessage)convertTransactionStateToPigeon: (SKPaymentTransactionState)state { switch (state) { case SKPaymentTransactionStatePurchasing: - return SKPaymentTransactionStateMessagePurchasing; + return FIASKPaymentTransactionStateMessagePurchasing; case SKPaymentTransactionStatePurchased: - return SKPaymentTransactionStateMessagePurchased; + return FIASKPaymentTransactionStateMessagePurchased; case SKPaymentTransactionStateFailed: - return SKPaymentTransactionStateMessageFailed; + return FIASKPaymentTransactionStateMessageFailed; case SKPaymentTransactionStateRestored: - return SKPaymentTransactionStateMessageRestored; + return FIASKPaymentTransactionStateMessageRestored; case SKPaymentTransactionStateDeferred: - return SKPaymentTransactionStateMessageDeferred; + return FIASKPaymentTransactionStateMessageDeferred; } } -+ (nullable SKPaymentMessage *)convertPaymentToPigeon:(nullable SKPayment *)payment ++ (nullable FIASKPaymentMessage *)convertPaymentToPigeon:(nullable SKPayment *)payment API_AVAILABLE(ios(12.2)) { if (!payment) { return nil; } - SKPaymentMessage *msg = [SKPaymentMessage + return [FIASKPaymentMessage makeWithProductIdentifier:payment.productIdentifier applicationUsername:payment.applicationUsername requestData:[[NSString alloc] initWithData:payment.requestData @@ -355,92 +351,85 @@ + (nullable SKPaymentMessage *)convertPaymentToPigeon:(nullable SKPayment *)paym quantity:payment.quantity simulatesAskToBuyInSandbox:payment.simulatesAskToBuyInSandbox paymentDiscount:[self convertPaymentDiscountToPigeon:payment.paymentDiscount]]; - return msg; } -+ (nullable SKPaymentDiscountMessage *)convertPaymentDiscountToPigeon: ++ (nullable FIASKPaymentDiscountMessage *)convertPaymentDiscountToPigeon: (nullable SKPaymentDiscount *)discount API_AVAILABLE(ios(12.2)) { if (!discount) { return nil; } - SKPaymentDiscountMessage *msg = - [SKPaymentDiscountMessage makeWithIdentifier:discount.identifier - keyIdentifier:discount.keyIdentifier - nonce:[discount.nonce UUIDString] - signature:discount.signature - timestamp:[discount.timestamp intValue]]; - - return msg; + return [FIASKPaymentDiscountMessage makeWithIdentifier:discount.identifier + keyIdentifier:discount.keyIdentifier + nonce:[discount.nonce UUIDString] + signature:discount.signature + timestamp:[discount.timestamp intValue]]; } -+ (nullable SKStorefrontMessage *)convertStorefrontToPigeon:(nullable SKStorefront *)storefront ++ (nullable FIASKStorefrontMessage *)convertStorefrontToPigeon:(nullable SKStorefront *)storefront API_AVAILABLE(ios(13.0)) { if (!storefront) { return nil; } - SKStorefrontMessage *msg = [SKStorefrontMessage makeWithCountryCode:storefront.countryCode - identifier:storefront.identifier]; - return msg; + return [FIASKStorefrontMessage makeWithCountryCode:storefront.countryCode + identifier:storefront.identifier]; } -+ (nullable SKProductSubscriptionPeriodMessage *)convertSKProductSubscriptionPeriodToPigeon: ++ (nullable FIASKProductSubscriptionPeriodMessage *)convertSKProductSubscriptionPeriodToPigeon: (nullable SKProductSubscriptionPeriod *)period API_AVAILABLE(ios(12.2)) { if (!period) { return nil; } - SKSubscriptionPeriodUnitMessage unit; + FIASKSubscriptionPeriodUnitMessage unit; switch (period.unit) { case SKProductPeriodUnitDay: - unit = SKSubscriptionPeriodUnitMessageDay; + unit = FIASKSubscriptionPeriodUnitMessageDay; break; case SKProductPeriodUnitWeek: - unit = SKSubscriptionPeriodUnitMessageWeek; + unit = FIASKSubscriptionPeriodUnitMessageWeek; break; case SKProductPeriodUnitMonth: - unit = SKSubscriptionPeriodUnitMessageMonth; + unit = FIASKSubscriptionPeriodUnitMessageMonth; break; case SKProductPeriodUnitYear: - unit = SKSubscriptionPeriodUnitMessageYear; + unit = FIASKSubscriptionPeriodUnitMessageYear; break; } - SKProductSubscriptionPeriodMessage *msg = - [SKProductSubscriptionPeriodMessage makeWithNumberOfUnits:period.numberOfUnits unit:unit]; - - return msg; + return [FIASKProductSubscriptionPeriodMessage makeWithNumberOfUnits:period.numberOfUnits + unit:unit]; } -+ (nullable SKProductDiscountMessage *)convertProductDiscountToPigeon: ++ (nullable FIASKProductDiscountMessage *)convertProductDiscountToPigeon: (nullable SKProductDiscount *)productDiscount API_AVAILABLE(ios(12.2)) { if (!productDiscount) { return nil; } - SKProductDiscountPaymentModeMessage paymentMode; + FIASKProductDiscountPaymentModeMessage paymentMode; switch (productDiscount.paymentMode) { case SKProductDiscountPaymentModeFreeTrial: - paymentMode = SKProductDiscountPaymentModeMessageFreeTrial; + paymentMode = FIASKProductDiscountPaymentModeMessageFreeTrial; break; case SKProductDiscountPaymentModePayAsYouGo: - paymentMode = SKProductDiscountPaymentModeMessagePayAsYouGo; + paymentMode = FIASKProductDiscountPaymentModeMessagePayAsYouGo; break; case SKProductDiscountPaymentModePayUpFront: - paymentMode = SKProductDiscountPaymentModeMessagePayUpFront; + paymentMode = FIASKProductDiscountPaymentModeMessagePayUpFront; break; } - SKProductDiscountTypeMessage type; + FIASKProductDiscountTypeMessage type; switch (productDiscount.type) { case SKProductDiscountTypeIntroductory: - type = SKProductDiscountTypeMessageIntroductory; + type = FIASKProductDiscountTypeMessageIntroductory; break; case SKProductDiscountTypeSubscription: - type = SKProductDiscountTypeMessageSubscription; + type = FIASKProductDiscountTypeMessageSubscription; break; } - SKProductDiscountMessage *msg = [SKProductDiscountMessage + return [FIASKProductDiscountMessage makeWithPrice:productDiscount.price.description priceLocale:[self convertNSLocaleToPigeon:productDiscount.priceLocale] numberOfPeriods:productDiscount.numberOfPeriods @@ -449,37 +438,33 @@ + (nullable SKProductDiscountMessage *)convertProductDiscountToPigeon: .subscriptionPeriod] identifier:productDiscount.identifier type:type]; - - return msg; } -+ (nullable SKPriceLocaleMessage *)convertNSLocaleToPigeon:(nullable NSLocale *)locale ++ (nullable FIASKPriceLocaleMessage *)convertNSLocaleToPigeon:(nullable NSLocale *)locale API_AVAILABLE(ios(12.2)) { if (!locale) { return nil; } - SKPriceLocaleMessage *msg = [SKPriceLocaleMessage makeWithCurrencySymbol:locale.currencySymbol - currencyCode:locale.currencyCode - countryCode:locale.countryCode]; - - return msg; + return [FIASKPriceLocaleMessage makeWithCurrencySymbol:locale.currencySymbol + currencyCode:locale.currencyCode + countryCode:locale.countryCode]; } -+ (nullable SKProductMessage *)convertProductToPigeon:(nullable SKProduct *)product ++ (nullable FIASKProductMessage *)convertProductToPigeon:(nullable SKProduct *)product API_AVAILABLE(ios(12.2)) { if (!product) { return nil; } NSArray *skProductDiscounts = product.discounts; - NSMutableArray *pigeonProductDiscounts = + NSMutableArray *pigeonProductDiscounts = [NSMutableArray arrayWithCapacity:skProductDiscounts.count]; for (SKProductDiscount *productDiscount in skProductDiscounts) { [pigeonProductDiscounts addObject:[self convertProductDiscountToPigeon:productDiscount]]; }; - SKProductMessage *msg = [SKProductMessage + return [FIASKProductMessage makeWithProductIdentifier:product.productIdentifier localizedTitle:product.localizedTitle localizedDescription:product.localizedDescription @@ -490,27 +475,24 @@ + (nullable SKProductMessage *)convertProductToPigeon:(nullable SKProduct *)prod [self convertSKProductSubscriptionPeriodToPigeon:product.subscriptionPeriod] introductoryPrice:[self convertProductDiscountToPigeon:product.introductoryPrice] discounts:pigeonProductDiscounts]; - - return msg; } -+ (nullable SKProductsResponseMessage *)convertProductsResponseToPigeon: ++ (nullable FIASKProductsResponseMessage *)convertProductsResponseToPigeon: (nullable SKProductsResponse *)productsResponse API_AVAILABLE(ios(12.2)) { if (!productsResponse) { return nil; } NSArray *skProducts = productsResponse.products; - NSMutableArray *pigeonProducts = + NSMutableArray *pigeonProducts = [NSMutableArray arrayWithCapacity:skProducts.count]; for (SKProduct *product in skProducts) { [pigeonProducts addObject:[self convertProductToPigeon:product]]; }; - SKProductsResponseMessage *msg = [SKProductsResponseMessage + return [FIASKProductsResponseMessage makeWithProducts:pigeonProducts invalidProductIdentifiers:productsResponse.invalidProductIdentifiers ?: @[]]; - return msg; } @end 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 a591739eb69..364d977fb40 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 @@ -11,7 +11,7 @@ import StoreKit import FlutterMacOS #endif -public class InAppPurchasePlugin: NSObject, FlutterPlugin, InAppPurchaseAPI { +public class InAppPurchasePlugin: NSObject, FlutterPlugin, FIAInAppPurchaseAPI { private let receiptManager: FIAPReceiptManager private var productsCache: NSMutableDictionary = [:] private var paymentQueueDelegateCallbackChannel: FlutterMethodChannel? @@ -40,7 +40,7 @@ public class InAppPurchasePlugin: NSObject, FlutterPlugin, InAppPurchaseAPI { let instance = InAppPurchasePlugin(registrar: registrar) registrar.addMethodCallDelegate(instance, channel: channel) registrar.addApplicationDelegate(instance) - SetUpInAppPurchaseAPI(messenger, instance) + SetUpFIAInAppPurchaseAPI(messenger, instance) if #available(iOS 15.0, macOS 12.0, *) { InAppPurchase2APISetup.setUp(binaryMessenger: messenger, api: instance) } @@ -104,7 +104,7 @@ public class InAppPurchasePlugin: NSObject, FlutterPlugin, InAppPurchaseAPI { } public func transactionsWithError(_ error: AutoreleasingUnsafeMutablePointer) - -> [SKPaymentTransactionMessage]? + -> [FIASKPaymentTransactionMessage]? { return getPaymentQueueHandler() .getUnfinishedTransactions() @@ -114,7 +114,7 @@ public class InAppPurchasePlugin: NSObject, FlutterPlugin, InAppPurchaseAPI { } public func storefrontWithError(_ error: AutoreleasingUnsafeMutablePointer) - -> SKStorefrontMessage? + -> FIASKStorefrontMessage? { if #available(iOS 13.0, *), let storefront = getPaymentQueueHandler().storefront { return FIAObjectTranslator.convertStorefront(toPigeon: storefront) @@ -124,7 +124,7 @@ public class InAppPurchasePlugin: NSObject, FlutterPlugin, InAppPurchaseAPI { public func startProductRequestProductIdentifiers( _ productIdentifiers: [String], - completion: @escaping (SKProductsResponseMessage?, FlutterError?) -> Void + completion: @escaping (FIASKProductsResponseMessage?, FlutterError?) -> Void ) { let request = getProductRequest(withIdentifiers: Set(productIdentifiers)) let handler = handlerFactory(request) From 4332b8f00697d2e593e0fcc4f69ab3826a2f51f5 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 8 Oct 2024 13:02:21 -0400 Subject: [PATCH 07/10] Test type updates --- .../example/shared/RunnerTests/TranslatorTests.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/TranslatorTests.swift b/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/TranslatorTests.swift index 204b2f2dbfc..f7e38480403 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/TranslatorTests.swift +++ b/packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/TranslatorTests.swift @@ -473,7 +473,7 @@ final class ObjectTranslatorTest: XCTestCase { func testSKErrorConvertToPigeon() throws { let error = NSError(domain: SKErrorDomain, code: 3, userInfo: ["key": 42]) - let msg = SKErrorMessage.make( + let msg = FIASKErrorMessage.make( withCode: 3, domain: SKErrorDomain, userInfo: ["key": 42] as [String: Any]) let skerror = try XCTUnwrap(FIAObjectTranslator.convertSKError(toPigeon: error)) @@ -507,7 +507,7 @@ final class ObjectTranslatorTest: XCTestCase { let unwrappedMsg = try XCTUnwrap(msg) let unwrappedTimeStamp = try XCTUnwrap(unwrappedMsg.transactionTimeStamp) - XCTAssertEqual(unwrappedMsg.transactionState, SKPaymentTransactionStateMessage.purchasing) + XCTAssertEqual(unwrappedMsg.transactionState, FIASKPaymentTransactionStateMessage.purchasing) XCTAssertEqual( paymentTransaction.transactionDate, Date(timeIntervalSince1970: TimeInterval(truncating: unwrappedTimeStamp))) @@ -537,13 +537,13 @@ final class ObjectTranslatorTest: XCTestCase { XCTAssertEqual(localeMsg.currencySymbol, "\u{00a4}") let subPeriod = try XCTUnwrap(productMsg.subscriptionPeriod) - XCTAssertEqual(subPeriod.unit, SKSubscriptionPeriodUnitMessage.day) + XCTAssertEqual(subPeriod.unit, FIASKSubscriptionPeriodUnitMessage.day) XCTAssertEqual(subPeriod.numberOfUnits, 0) let introDiscount = try XCTUnwrap(productMsg.introductoryPrice) XCTAssertEqual(introDiscount.price, "1") XCTAssertEqual(introDiscount.numberOfPeriods, 1) - XCTAssertEqual(introDiscount.paymentMode, SKProductDiscountPaymentModeMessage.payUpFront) + XCTAssertEqual(introDiscount.paymentMode, FIASKProductDiscountPaymentModeMessage.payUpFront) let discounts = try XCTUnwrap(productMsg.discounts) XCTAssertEqual(discounts.count, 1) From a612f4b7b0d7291d2a6efed8060bbbadb2342edd Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Fri, 18 Oct 2024 14:54:29 -0400 Subject: [PATCH 08/10] Update the non-yet-used SK2ErrorMessage nullability --- .../Classes/StoreKit2/sk2_pigeon.g.swift | 26 +++++++------------ .../lib/src/sk2_pigeon.g.dart | 8 +++--- .../pigeons/sk2_pigeon.dart | 2 +- .../test/sk2_test_api.g.dart | 5 ++-- 4 files changed, 16 insertions(+), 25 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/StoreKit2/sk2_pigeon.g.swift b/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/StoreKit2/sk2_pigeon.g.swift index 386786d6bae..f6ff6bfe63b 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/StoreKit2/sk2_pigeon.g.swift +++ b/packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/StoreKit2/sk2_pigeon.g.swift @@ -291,11 +291,7 @@ struct SK2ProductPurchaseOptionsMessage { // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2ProductPurchaseOptionsMessage? { let appAccountToken: String? = nilOrValue(pigeonVar_list[0]) - let quantity: Int64? = - isNullish(pigeonVar_list[1]) - ? nil - : (pigeonVar_list[1] is Int64? - ? pigeonVar_list[1] as! Int64? : Int64(pigeonVar_list[1] as! Int32)) + let quantity: Int64? = nilOrValue(pigeonVar_list[1]) return SK2ProductPurchaseOptionsMessage( appAccountToken: appAccountToken, @@ -323,14 +319,11 @@ struct SK2TransactionMessage { // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2TransactionMessage? { - let id = - pigeonVar_list[0] is Int64 ? pigeonVar_list[0] as! Int64 : Int64(pigeonVar_list[0] as! Int32) - let originalId = - pigeonVar_list[1] is Int64 ? pigeonVar_list[1] as! Int64 : Int64(pigeonVar_list[1] as! Int32) + let id = pigeonVar_list[0] as! Int64 + let originalId = pigeonVar_list[1] as! Int64 let productId = pigeonVar_list[2] as! String let purchaseDate = pigeonVar_list[3] as! String - let purchasedQuantity = - pigeonVar_list[4] is Int64 ? pigeonVar_list[4] as! Int64 : Int64(pigeonVar_list[4] as! Int32) + let purchasedQuantity = pigeonVar_list[4] as! Int64 let appAccountToken: String? = nilOrValue(pigeonVar_list[5]) let restoring = pigeonVar_list[6] as! Bool let error: SK2ErrorMessage? = nilOrValue(pigeonVar_list[7]) @@ -364,14 +357,13 @@ struct SK2TransactionMessage { struct SK2ErrorMessage { var code: Int64 var domain: String - var userInfo: [String?: Any?]? = nil + var userInfo: [String: Any]? = nil // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> SK2ErrorMessage? { - let code = - pigeonVar_list[0] is Int64 ? pigeonVar_list[0] as! Int64 : Int64(pigeonVar_list[0] as! Int32) + let code = pigeonVar_list[0] as! Int64 let domain = pigeonVar_list[1] as! String - let userInfo: [String?: Any?]? = nilOrValue(pigeonVar_list[2]) + let userInfo: [String: Any]? = nilOrValue(pigeonVar_list[2]) return SK2ErrorMessage( code: code, @@ -416,7 +408,7 @@ private class sk2_pigeonPigeonCodecReader: FlutterStandardReader { } return nil case 133: - let enumResultAsInt: Int? = nilOrValue(self.readValue() as? Int) + let enumResultAsInt: Int? = nilOrValue(self.readValue() as! Int?) if let enumResultAsInt = enumResultAsInt { return SK2ProductPurchaseResultMessage(rawValue: enumResultAsInt) } @@ -608,7 +600,7 @@ class InAppPurchase2APISetup { if let api = api { finishChannel.setMessageHandler { message, reply in let args = message as! [Any?] - let idArg = args[0] is Int64 ? args[0] as! Int64 : Int64(args[0] as! Int32) + let idArg = args[0] as! Int64 api.finish(id: idArg) { result in switch result { case .success: diff --git a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/sk2_pigeon.g.dart b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/sk2_pigeon.g.dart index f16a48b758f..8c6753fdf20 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/sk2_pigeon.g.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/sk2_pigeon.g.dart @@ -361,7 +361,7 @@ class SK2ErrorMessage { String domain; - Map? userInfo; + Map? userInfo; Object encode() { return [ @@ -376,7 +376,7 @@ class SK2ErrorMessage { return SK2ErrorMessage( code: result[0]! as int, domain: result[1]! as String, - userInfo: (result[2] as Map?)?.cast(), + userInfo: (result[2] as Map?)?.cast(), ); } } @@ -584,7 +584,7 @@ class InAppPurchase2API { } } - Future> transactions() async { + Future> transactions() async { final String pigeonVar_channelName = 'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2API.transactions$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = @@ -610,7 +610,7 @@ class InAppPurchase2API { ); } else { return (pigeonVar_replyList[0] as List?)! - .cast(); + .cast(); } } diff --git a/packages/in_app_purchase/in_app_purchase_storekit/pigeons/sk2_pigeon.dart b/packages/in_app_purchase/in_app_purchase_storekit/pigeons/sk2_pigeon.dart index c77ee9bd098..fbf4c421ac1 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/pigeons/sk2_pigeon.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/pigeons/sk2_pigeon.dart @@ -161,7 +161,7 @@ class SK2ErrorMessage { final int code; final String domain; - final Map? userInfo; + final Map? userInfo; } enum SK2ProductPurchaseResultMessage { success, userCancelled, pending } diff --git a/packages/in_app_purchase/in_app_purchase_storekit/test/sk2_test_api.g.dart b/packages/in_app_purchase/in_app_purchase_storekit/test/sk2_test_api.g.dart index 2680cf9bcda..58850af3ece 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/test/sk2_test_api.g.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/test/sk2_test_api.g.dart @@ -124,7 +124,7 @@ abstract class TestInAppPurchase2Api { Future purchase(String id, {SK2ProductPurchaseOptionsMessage? options}); - Future> transactions(); + Future> transactions(); Future finish(int id); @@ -249,8 +249,7 @@ abstract class TestInAppPurchase2Api { .setMockDecodedMessageHandler(pigeonVar_channel, (Object? message) async { try { - final List output = - await api.transactions(); + final List output = await api.transactions(); return [output]; } on PlatformException catch (e) { return wrapResponse(error: e); From 9a327391b19b693208163e94365cd37578e333e4 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Fri, 18 Oct 2024 14:55:51 -0400 Subject: [PATCH 09/10] Remove unnecessary cast --- .../src/store_kit_2_wrappers/sk2_transaction_wrapper.dart | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_2_wrappers/sk2_transaction_wrapper.dart b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_2_wrappers/sk2_transaction_wrapper.dart index c6ec3bf0d5a..5afefddba7a 100644 --- a/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_2_wrappers/sk2_transaction_wrapper.dart +++ b/packages/in_app_purchase/in_app_purchase_storekit/lib/src/store_kit_2_wrappers/sk2_transaction_wrapper.dart @@ -70,11 +70,9 @@ class SK2Transaction { /// https://developer.apple.com/documentation/storekit/transaction/3851203-all /// A sequence that emits all the customer’s transactions for your app. static Future> transactions() async { - final List msgs = await _hostApi.transactions(); - final List transactions = msgs - .map((SK2TransactionMessage? e) => e?.convertFromPigeon()) - .cast() - .toList(); + final List msgs = await _hostApi.transactions(); + final List transactions = + msgs.map((SK2TransactionMessage e) => e.convertFromPigeon()).toList(); return transactions; } From 8162b28ec9586bbe354229e9db1fe988cf3d6a54 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Fri, 18 Oct 2024 15:07:25 -0400 Subject: [PATCH 10/10] Update test --- .../test/fakes/fake_storekit_platform.dart | 4 ++-- 1 file changed, 2 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 59b05298c22..29932a9f818 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 @@ -352,8 +352,8 @@ class FakeStoreKit2Platform implements TestInAppPurchase2Api { } @override - Future> transactions() { - return Future>.value([ + Future> transactions() { + return Future>.value([ SK2TransactionMessage( id: 123, originalId: 123,