diff --git a/packages/in_app_purchase/CHANGELOG.md b/packages/in_app_purchase/CHANGELOG.md index 940909b10d0d..1a64a43b314c 100644 --- a/packages/in_app_purchase/CHANGELOG.md +++ b/packages/in_app_purchase/CHANGELOG.md @@ -1,6 +1,7 @@ ## 0.2.1+5 * Define clang module for iOS. +* Fix iOS build warning. ## 0.2.1+4 diff --git a/packages/in_app_purchase/ios/Classes/InAppPurchasePlugin.h b/packages/in_app_purchase/ios/Classes/InAppPurchasePlugin.h index 67a381d31283..a7c00f18bc37 100644 --- a/packages/in_app_purchase/ios/Classes/InAppPurchasePlugin.h +++ b/packages/in_app_purchase/ios/Classes/InAppPurchasePlugin.h @@ -10,6 +10,8 @@ @property(strong, nonatomic) FIAPaymentQueueHandler *paymentQueueHandler; -- (instancetype)initWithReceiptManager:(FIAPReceiptManager *)receiptManager; +- (instancetype)initWithReceiptManager:(FIAPReceiptManager *)receiptManager + NS_DESIGNATED_INITIALIZER; +- (instancetype)init NS_UNAVAILABLE; @end diff --git a/packages/in_app_purchase/ios/Classes/InAppPurchasePlugin.m b/packages/in_app_purchase/ios/Classes/InAppPurchasePlugin.m index eb158338a752..84dd457e7d35 100644 --- a/packages/in_app_purchase/ios/Classes/InAppPurchasePlugin.m +++ b/packages/in_app_purchase/ios/Classes/InAppPurchasePlugin.m @@ -13,19 +13,19 @@ @interface InAppPurchasePlugin () // Holding strong references to FIAPRequestHandlers. Remove the handlers from the set after // the request is finished. -@property(strong, nonatomic) NSMutableSet *requestHandlers; +@property(strong, nonatomic, readonly) NSMutableSet *requestHandlers; // After querying the product, the available products will be saved in the map to be used // for purchase. -@property(copy, nonatomic) NSMutableDictionary *productsCache; +@property(strong, nonatomic, readonly) NSMutableDictionary *productsCache; // Call back channel to dart used for when a listener function is triggered. -@property(strong, nonatomic) FlutterMethodChannel *callbackChannel; -@property(strong, nonatomic) NSObject *registry; -@property(strong, nonatomic) NSObject *messenger; -@property(strong, nonatomic) NSObject *registrar; +@property(strong, nonatomic, readonly) FlutterMethodChannel *callbackChannel; +@property(strong, nonatomic, readonly) NSObject *registry; +@property(strong, nonatomic, readonly) NSObject *messenger; +@property(strong, nonatomic, readonly) NSObject *registrar; -@property(strong, nonatomic) FIAPReceiptManager *receiptManager; +@property(strong, nonatomic, readonly) FIAPReceiptManager *receiptManager; @end @@ -40,39 +40,40 @@ + (void)registerWithRegistrar:(NSObject *)registrar { } - (instancetype)initWithReceiptManager:(FIAPReceiptManager *)receiptManager { - self = [self init]; - self.receiptManager = receiptManager; + self = [super init]; + _receiptManager = receiptManager; + _requestHandlers = [NSMutableSet new]; + _productsCache = [NSMutableDictionary new]; return self; } - (instancetype)initWithRegistrar:(NSObject *)registrar { self = [self initWithReceiptManager:[FIAPReceiptManager new]]; - self.registrar = registrar; - self.registry = [registrar textures]; - self.messenger = [registrar messenger]; + _registrar = registrar; + _registry = [registrar textures]; + _messenger = [registrar messenger]; __weak typeof(self) weakSelf = self; - self.paymentQueueHandler = - [[FIAPaymentQueueHandler alloc] initWithQueue:[SKPaymentQueue defaultQueue] - transactionsUpdated:^(NSArray *_Nonnull transactions) { - [weakSelf handleTransactionsUpdated:transactions]; - } - transactionRemoved:^(NSArray *_Nonnull transactions) { - [weakSelf handleTransactionsRemoved:transactions]; - } - restoreTransactionFailed:^(NSError *_Nonnull error) { - [weakSelf handleTransactionRestoreFailed:error]; - } - restoreCompletedTransactionsFinished:^{ - [weakSelf restoreCompletedTransactionsFinished]; - } - shouldAddStorePayment:^BOOL(SKPayment *payment, SKProduct *product) { - return [weakSelf shouldAddStorePayment:payment product:product]; - } - updatedDownloads:^void(NSArray *_Nonnull downloads) { - [weakSelf updatedDownloads:downloads]; - }]; - self.callbackChannel = + _paymentQueueHandler = [[FIAPaymentQueueHandler alloc] initWithQueue:[SKPaymentQueue defaultQueue] + transactionsUpdated:^(NSArray *_Nonnull transactions) { + [weakSelf handleTransactionsUpdated:transactions]; + } + transactionRemoved:^(NSArray *_Nonnull transactions) { + [weakSelf handleTransactionsRemoved:transactions]; + } + restoreTransactionFailed:^(NSError *_Nonnull error) { + [weakSelf handleTransactionRestoreFailed:error]; + } + restoreCompletedTransactionsFinished:^{ + [weakSelf restoreCompletedTransactionsFinished]; + } + shouldAddStorePayment:^BOOL(SKPayment *payment, SKProduct *product) { + return [weakSelf shouldAddStorePayment:payment product:product]; + } + updatedDownloads:^void(NSArray *_Nonnull downloads) { + [weakSelf updatedDownloads:downloads]; + }]; + _callbackChannel = [FlutterMethodChannel methodChannelWithName:@"plugins.flutter.io/in_app_purchase_callback" binaryMessenger:[registrar messenger]]; return self; @@ -320,20 +321,4 @@ - (SKReceiptRefreshRequest *)getRefreshReceiptRequest:(NSDictionary *)properties return [[SKReceiptRefreshRequest alloc] initWithReceiptProperties:properties]; } -#pragma mark - getter - -- (NSSet *)requestHandlers { - if (!_requestHandlers) { - _requestHandlers = [NSMutableSet new]; - } - return _requestHandlers; -} - -- (NSMutableDictionary *)productsCache { - if (!_productsCache) { - _productsCache = [NSMutableDictionary new]; - } - return _productsCache; -} - @end diff --git a/script/lint_darwin_plugins.sh b/script/lint_darwin_plugins.sh index 3ca9af8b892a..94041c728191 100755 --- a/script/lint_darwin_plugins.sh +++ b/script/lint_darwin_plugins.sh @@ -21,7 +21,6 @@ function lint_package() { # TODO: These packages have analyzer warnings. Remove plugins from this list as issues are fixed. local skip_analysis_packages=( "camera.podspec" # https://github.com/flutter/flutter/issues/42673 - "in_app_purchase.podspec" # https://github.com/flutter/flutter/issues/42679 ) find "${package_dir}" -type f -name "*\.podspec" | while read podspec; do local podspecBasename=$(basename "${podspec}")