Skip to content

Commit d7ebbe2

Browse files
authored
[in_app_purchase_storekit] Remove availability checks below the package minimum iOS 13 and macOS 10.15 (flutter#13217)
iOS 13 and macOS 10.15 are always available: https://github.com/flutter/packages/blob/01d08731727c8dfcd9519cdbf376aa40499dc8f7/packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Package.swift#L13-L14 Remove old availability checks. ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent 01d0873 commit d7ebbe2

11 files changed

Lines changed: 42 additions & 65 deletions

File tree

‎packages/in_app_purchase/in_app_purchase_storekit/CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.4.13+2
2+
3+
* Removes availability checks for iOS and macOS versions below the package minimum (iOS 13 and macOS 10.15).
4+
15
## 0.4.13+1
26

37
* Fixes `completePurchase` never completing with StoreKit 2 when the transaction

‎packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit/InAppPurchasePlugin.swift‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ public class InAppPurchasePlugin: NSObject, FlutterPlugin, FIAInAppPurchaseAPI {
1919
private let receiptManager: FIAPReceiptManager
2020
private var productsCache: NSMutableDictionary = [:]
2121
private var paymentQueueDelegateCallbackChannel: FlutterMethodChannel?
22-
// note - the type should be FIAPPaymentQueueDelegate, but this is only available >= iOS 13,
23-
// FIAPPaymentQueueDelegate only gets set/used in registerPaymentQueueDelegateWithError or removePaymentQueueDelegateWithError, which both are ios13+ only
24-
private var paymentQueueDelegate: Any?
22+
private var paymentQueueDelegate: FIAPPaymentQueueDelegate?
2523
// Swift sets do not accept protocols, only concrete implementations
2624
// TODO(louisehsu): Change it back to a set when removing obj-c dependancies from this file via type erasure
2725
private var requestHandlers = NSHashTable<FLTRequestHandlerProtocol>()
@@ -349,7 +347,7 @@ public class InAppPurchasePlugin: NSObject, FlutterPlugin, FIAInAppPurchaseAPI {
349347
paymentQueueDelegate = FIAPPaymentQueueDelegate(
350348
methodChannel: DefaultMethodChannel(channel: unwrappedChannel))
351349

352-
getPaymentQueueHandler().delegate = paymentQueueDelegate as? SKPaymentQueueDelegate
350+
getPaymentQueueHandler().delegate = paymentQueueDelegate
353351
#endif
354352
}
355353

‎packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit_objc/FIAObjectTranslator.m‎

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ + (SKPaymentDiscount *)getSKPaymentDiscountFromMap:(NSDictionary *)map
267267
}
268268

269269
+ (nullable FIASKPaymentTransactionMessage *)convertTransactionToPigeon:
270-
(nullable SKPaymentTransaction *)transaction API_AVAILABLE(ios(12.2)) {
270+
(nullable SKPaymentTransaction *)transaction {
271271
if (!transaction) {
272272
return nil;
273273
}
@@ -313,8 +313,7 @@ + (FIASKPaymentTransactionStateMessage)convertTransactionStateToPigeon:
313313
}
314314
}
315315

316-
+ (nullable FIASKPaymentMessage *)convertPaymentToPigeon:(nullable SKPayment *)payment
317-
API_AVAILABLE(ios(12.2)) {
316+
+ (nullable FIASKPaymentMessage *)convertPaymentToPigeon:(nullable SKPayment *)payment {
318317
if (!payment) {
319318
return nil;
320319
}
@@ -329,7 +328,7 @@ + (nullable FIASKPaymentMessage *)convertPaymentToPigeon:(nullable SKPayment *)p
329328
}
330329

331330
+ (nullable FIASKPaymentDiscountMessage *)convertPaymentDiscountToPigeon:
332-
(nullable SKPaymentDiscount *)discount API_AVAILABLE(ios(12.2)) {
331+
(nullable SKPaymentDiscount *)discount {
333332
if (!discount) {
334333
return nil;
335334
}
@@ -340,8 +339,7 @@ + (nullable FIASKPaymentDiscountMessage *)convertPaymentDiscountToPigeon:
340339
timestamp:[discount.timestamp intValue]];
341340
}
342341

343-
+ (nullable FIASKStorefrontMessage *)convertStorefrontToPigeon:(nullable SKStorefront *)storefront
344-
API_AVAILABLE(ios(13.0)) {
342+
+ (nullable FIASKStorefrontMessage *)convertStorefrontToPigeon:(nullable SKStorefront *)storefront {
345343
if (!storefront) {
346344
return nil;
347345
}
@@ -350,7 +348,7 @@ + (nullable FIASKStorefrontMessage *)convertStorefrontToPigeon:(nullable SKStore
350348
}
351349

352350
+ (nullable FIASKProductSubscriptionPeriodMessage *)convertSKProductSubscriptionPeriodToPigeon:
353-
(nullable SKProductSubscriptionPeriod *)period API_AVAILABLE(ios(12.2)) {
351+
(nullable SKProductSubscriptionPeriod *)period {
354352
if (!period) {
355353
return nil;
356354
}
@@ -376,7 +374,7 @@ + (nullable FIASKProductSubscriptionPeriodMessage *)convertSKProductSubscription
376374
}
377375

378376
+ (nullable FIASKProductDiscountMessage *)convertProductDiscountToPigeon:
379-
(nullable SKProductDiscount *)productDiscount API_AVAILABLE(ios(12.2)) {
377+
(nullable SKProductDiscount *)productDiscount {
380378
if (!productDiscount) {
381379
return nil;
382380
}
@@ -415,8 +413,7 @@ + (nullable FIASKProductDiscountMessage *)convertProductDiscountToPigeon:
415413
type:type];
416414
}
417415

418-
+ (nullable FIASKPriceLocaleMessage *)convertNSLocaleToPigeon:(nullable NSLocale *)locale
419-
API_AVAILABLE(ios(12.2)) {
416+
+ (nullable FIASKPriceLocaleMessage *)convertNSLocaleToPigeon:(nullable NSLocale *)locale {
420417
if (!locale) {
421418
return nil;
422419
}
@@ -425,8 +422,7 @@ + (nullable FIASKPriceLocaleMessage *)convertNSLocaleToPigeon:(nullable NSLocale
425422
countryCode:locale.countryCode];
426423
}
427424

428-
+ (nullable FIASKProductMessage *)convertProductToPigeon:(nullable SKProduct *)product
429-
API_AVAILABLE(ios(12.2)) {
425+
+ (nullable FIASKProductMessage *)convertProductToPigeon:(nullable SKProduct *)product {
430426
if (!product) {
431427
return nil;
432428
}
@@ -453,7 +449,7 @@ + (nullable FIASKProductMessage *)convertProductToPigeon:(nullable SKProduct *)p
453449
}
454450

455451
+ (nullable FIASKProductsResponseMessage *)convertProductsResponseToPigeon:
456-
(nullable SKProductsResponse *)productsResponse API_AVAILABLE(ios(12.2)) {
452+
(nullable SKProductsResponse *)productsResponse {
457453
if (!productsResponse) {
458454
return nil;
459455
}

‎packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit_objc/FIAPaymentQueueHandler.m‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ - (BOOL)paymentQueue:(SKPaymentQueue *)queue
233233
return self.queue.transactions;
234234
}
235235

236-
- (SKStorefront *)storefront API_AVAILABLE(ios(13.0)) {
236+
- (SKStorefront *)storefront {
237237
return self.queue.storefront;
238238
}
239239

‎packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit_objc/Protocols/FLTPaymentQueueProtocol.m‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,15 @@ - (void)restoreCompletedTransactionsWithApplicationUsername:(nullable NSString *
4343
[self.queue restoreCompletedTransactionsWithApplicationUsername:username];
4444
}
4545

46-
- (id<SKPaymentQueueDelegate>)delegate API_AVAILABLE(ios(13.0), macos(10.15), watchos(6.2)) {
46+
- (id<SKPaymentQueueDelegate>)delegate {
4747
return self.queue.delegate;
4848
}
4949

50-
- (NSArray<SKPaymentTransaction *> *)transactions API_AVAILABLE(ios(3.0), macos(10.7),
51-
watchos(6.2)) {
50+
- (NSArray<SKPaymentTransaction *> *)transactions {
5251
return self.queue.transactions;
5352
}
5453

55-
- (SKStorefront *)storefront API_AVAILABLE(ios(13.0)) {
54+
- (SKStorefront *)storefront {
5655
return self.queue.storefront;
5756
}
5857

‎packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit_objc/include/in_app_purchase_storekit_objc/FIAObjectTranslator.h‎

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,14 @@ NS_ASSUME_NONNULL_BEGIN
1414
+ (NSDictionary *)getMapFromSKProduct:(SKProduct *)product;
1515

1616
// Converts an instance of SKProductSubscriptionPeriod into a dictionary.
17-
+ (NSDictionary *)getMapFromSKProductSubscriptionPeriod:(SKProductSubscriptionPeriod *)period
18-
API_AVAILABLE(ios(11.2));
17+
+ (NSDictionary *)getMapFromSKProductSubscriptionPeriod:(SKProductSubscriptionPeriod *)period;
1918

2019
// Converts an instance of SKProductDiscount into a dictionary.
21-
+ (NSDictionary *)getMapFromSKProductDiscount:(SKProductDiscount *)discount
22-
API_AVAILABLE(ios(11.2));
20+
+ (NSDictionary *)getMapFromSKProductDiscount:(SKProductDiscount *)discount;
2321

2422
// Converts an array of SKProductDiscount instances into an array of dictionaries.
2523
+ (nonnull NSArray *)getMapArrayFromSKProductDiscounts:
26-
(nonnull NSArray<SKProductDiscount *> *)productDiscounts API_AVAILABLE(ios(12.2));
24+
(nonnull NSArray<SKProductDiscount *> *)productDiscounts;
2725

2826
// Converts an instance of SKProductsResponse into a dictionary.
2927
+ (NSDictionary *)getMapFromSKProductsResponse:(SKProductsResponse *)productResponse;
@@ -44,47 +42,40 @@ NS_ASSUME_NONNULL_BEGIN
4442
+ (NSDictionary *)getMapFromNSError:(NSError *)error;
4543

4644
// Converts an instance of SKStorefront into a dictionary.
47-
+ (NSDictionary *)getMapFromSKStorefront:(SKStorefront *)storefront
48-
API_AVAILABLE(ios(13), macos(10.15), watchos(6.2));
45+
+ (NSDictionary *)getMapFromSKStorefront:(SKStorefront *)storefront;
4946

5047
// Converts the supplied instances of SKStorefront and SKPaymentTransaction into a dictionary.
5148
+ (NSDictionary *)getMapFromSKStorefront:(SKStorefront *)storefront
52-
andSKPaymentTransaction:(SKPaymentTransaction *)transaction
53-
API_AVAILABLE(ios(13), macos(10.15), watchos(6.2));
49+
andSKPaymentTransaction:(SKPaymentTransaction *)transaction;
5450

5551
// Creates an instance of the SKPaymentDiscount class based on the supplied dictionary.
5652
+ (nullable SKPaymentDiscount *)getSKPaymentDiscountFromMap:(NSDictionary *)map
57-
withError:(NSString *_Nullable *_Nullable)error
58-
API_AVAILABLE(ios(12.2));
53+
withError:(NSString *_Nullable *_Nullable)error;
5954

6055
+ (nullable FIASKPaymentTransactionMessage *)convertTransactionToPigeon:
6156
(nullable SKPaymentTransaction *)transaction;
6257

63-
+ (nullable FIASKStorefrontMessage *)convertStorefrontToPigeon:(nullable SKStorefront *)storefront
64-
API_AVAILABLE(ios(13.0));
58+
+ (nullable FIASKStorefrontMessage *)convertStorefrontToPigeon:(nullable SKStorefront *)storefront;
6559

6660
+ (nullable FIASKPaymentDiscountMessage *)convertPaymentDiscountToPigeon:
67-
(nullable SKPaymentDiscount *)discount API_AVAILABLE(ios(12.2));
61+
(nullable SKPaymentDiscount *)discount;
6862

69-
+ (nullable FIASKPaymentMessage *)convertPaymentToPigeon:(nullable SKPayment *)payment
70-
API_AVAILABLE(ios(12.2));
63+
+ (nullable FIASKPaymentMessage *)convertPaymentToPigeon:(nullable SKPayment *)payment;
7164

7265
+ (nullable FIASKErrorMessage *)convertSKErrorToPigeon:(nullable NSError *)error;
7366

7467
+ (nullable FIASKProductsResponseMessage *)convertProductsResponseToPigeon:
7568
(nullable SKProductsResponse *)payment;
7669

77-
+ (nullable FIASKProductMessage *)convertProductToPigeon:(nullable SKProduct *)product
78-
API_AVAILABLE(ios(12.2));
70+
+ (nullable FIASKProductMessage *)convertProductToPigeon:(nullable SKProduct *)product;
7971

8072
+ (nullable FIASKProductDiscountMessage *)convertProductDiscountToPigeon:
81-
(nullable SKProductDiscount *)productDiscount API_AVAILABLE(ios(12.2));
73+
(nullable SKProductDiscount *)productDiscount;
8274

83-
+ (nullable FIASKPriceLocaleMessage *)convertNSLocaleToPigeon:(nullable NSLocale *)locale
84-
API_AVAILABLE(ios(12.2));
75+
+ (nullable FIASKPriceLocaleMessage *)convertNSLocaleToPigeon:(nullable NSLocale *)locale;
8576

8677
+ (nullable FIASKProductSubscriptionPeriodMessage *)convertSKProductSubscriptionPeriodToPigeon:
87-
(nullable SKProductSubscriptionPeriod *)period API_AVAILABLE(ios(12.2));
78+
(nullable SKProductSubscriptionPeriod *)period;
8879
@end
8980

9081
NS_ASSUME_NONNULL_END

‎packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit_objc/include/in_app_purchase_storekit_objc/FIAPPaymentQueueDelegate.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
NS_ASSUME_NONNULL_BEGIN
1616

17-
API_AVAILABLE(ios(13), macos(10.15))
1817
API_UNAVAILABLE(tvos, watchos)
1918
@interface FIAPPaymentQueueDelegate : NSObject <SKPaymentQueueDelegate>
2019
- (id)initWithMethodChannel:(id<FLTMethodChannelProtocol>)methodChannel;

‎packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit_objc/include/in_app_purchase_storekit_objc/FLTPaymentQueueHandlerProtocol.h‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ typedef void (^UpdatedDownloads)(NSArray<SKDownload *> *downloads);
1818
/// A protocol that conforms to SKPaymentTransactionObserver and handles SKPaymentQueue methods
1919
@protocol FLTPaymentQueueHandlerProtocol <NSObject, SKPaymentTransactionObserver>
2020
/// An object that provides information needed to complete transactions.
21-
@property(nonatomic, weak, nullable) id<SKPaymentQueueDelegate> delegate API_AVAILABLE(
22-
ios(13.0), macos(10.15), watchos(6.2));
21+
@property(nonatomic, weak, nullable) id<SKPaymentQueueDelegate> delegate;
2322
/// An object containing the location and unique identifier of an Apple App Store storefront.
24-
@property(nonatomic, readonly, nullable)
25-
SKStorefront *storefront API_AVAILABLE(ios(13.0), macos(10.15), watchos(6.2));
23+
@property(nonatomic, readonly, nullable) SKStorefront *storefront;
2624

2725
/// Creates a new FIAPaymentQueueHandler.
2826
///

‎packages/in_app_purchase/in_app_purchase_storekit/darwin/in_app_purchase_storekit/Sources/in_app_purchase_storekit_objc/include/in_app_purchase_storekit_objc/FLTPaymentQueueProtocol.h‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ NS_ASSUME_NONNULL_BEGIN
1010
@protocol FLTPaymentQueueProtocol <NSObject>
1111

1212
/// An object containing the location and unique identifier of an Apple App Store storefront.
13-
@property(nonatomic, strong) SKStorefront *storefront API_AVAILABLE(ios(13.0));
13+
@property(nonatomic, strong) SKStorefront *storefront;
1414

1515
/// A list of SKPaymentTransactions, which each represents a single transaction
16-
@property(nonatomic, strong) NSArray<SKPaymentTransaction *> *transactions API_AVAILABLE(
17-
ios(3.0), macos(10.7), watchos(6.2));
16+
@property(nonatomic, strong) NSArray<SKPaymentTransaction *> *transactions;
1817

1918
/// An object that provides information needed to complete transactions.
20-
@property(nonatomic, weak, nullable) id<SKPaymentQueueDelegate> delegate API_AVAILABLE(
21-
ios(13.0), macos(10.15), watchos(6.2));
19+
@property(nonatomic, weak, nullable) id<SKPaymentQueueDelegate> delegate;
2220

2321
/// Remove a finished (i.e. failed or completed) transaction from the queue. Attempting to finish a
2422
/// purchasing transaction will throw an exception.
@@ -34,13 +32,11 @@ NS_ASSUME_NONNULL_BEGIN
3432
- (void)addPayment:(SKPayment *_Nonnull)payment;
3533

3634
/// Will add completed transactions for the current user back to the queue to be re-completed.
37-
- (void)restoreCompletedTransactions API_AVAILABLE(ios(3.0), macos(10.7), watchos(6.2),
38-
visionos(1.0));
35+
- (void)restoreCompletedTransactions;
3936

4037
/// Will add completed transactions for the current user back to the queue to be re-completed. This
4138
/// version requires an identifier to the user's account.
42-
- (void)restoreCompletedTransactionsWithApplicationUsername:(nullable NSString *)username
43-
API_AVAILABLE(ios(7.0), macos(10.9), watchos(6.2));
39+
- (void)restoreCompletedTransactionsWithApplicationUsername:(nullable NSString *)username;
4440

4541
/// Call this method to have StoreKit present a sheet enabling the user to redeem codes provided by
4642
/// your app. Only for iOS.

‎packages/in_app_purchase/in_app_purchase_storekit/example/shared/RunnerTests/Stubs.h‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@
1818
#endif
1919

2020
NS_ASSUME_NONNULL_BEGIN
21-
API_AVAILABLE(ios(11.2), macos(10.13.2))
2221
@interface SKProductSubscriptionPeriodStub : SKProductSubscriptionPeriod
2322
- (instancetype)initWithMap:(NSDictionary *)map;
2423
@end
2524

26-
API_AVAILABLE(ios(11.2), macos(10.13.2))
2725
@interface SKProductDiscountStub : SKProductDiscount
2826
- (instancetype)initWithMap:(NSDictionary *)map;
2927
@end
@@ -74,7 +72,6 @@ API_AVAILABLE(ios(11.2), macos(10.13.2))
7472
- (instancetype)initWithFailureError:(NSError *)error;
7573
@end
7674

77-
API_AVAILABLE(ios(13.0), macos(10.15))
7875
@interface SKStorefrontStub : SKStorefront
7976
- (instancetype)initWithMap:(NSDictionary *)map;
8077
@end
@@ -85,9 +82,8 @@ API_AVAILABLE(ios(13.0), macos(10.15))
8582
// FLTPaymentQueueProtocol properties
8683
@property(nonatomic, assign) SKPaymentTransactionState paymentState;
8784
@property(nonatomic, strong, nullable) id<SKPaymentTransactionObserver> observer;
88-
@property(nonatomic, strong, readwrite) SKStorefront *storefront API_AVAILABLE(ios(13.0));
89-
@property(nonatomic, strong, readwrite) NSArray<SKPaymentTransaction *> *transactions API_AVAILABLE(
90-
ios(3.0), macos(10.7), watchos(6.2));
85+
@property(nonatomic, strong, readwrite) SKStorefront *storefront;
86+
@property(nonatomic, strong, readwrite) NSArray<SKPaymentTransaction *> *transactions;
9187

9288
// Test Properties
9389
@property(nonatomic, assign)

0 commit comments

Comments
 (0)