-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert startProductRequest(), finishTransaction(), restoreTransactions(), presentCodeRedemptionSheet() to pigeon #6032
Conversation
packages/in_app_purchase/in_app_purchase_storekit/example/ios/Runner.xcodeproj/project.pbxproj
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, the only major thing is the missing short circuiting and potentially missing tests for all these extra converters.
|
||
NSArray<SKProductDiscount *> *skProductDiscounts = product.discounts; | ||
NSMutableArray<SKProductDiscountMessage *> *pigeonProductDiscounts = | ||
[[NSMutableArray alloc] init]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: you know the size here. It's more efficient to create the array of the proper size.
[[NSMutableArray alloc] init]; | |
[NSMutableArray arrayWithCapacity: skProductDiscounts.count]; |
return nil; | ||
} | ||
NSArray<SKProduct *> *skProducts = productsResponse.products; | ||
NSMutableArray<SKProductMessage *> *pigeonProducts = [[NSMutableArray alloc] init]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: same here
NSMutableArray<SKProductMessage *> *pigeonProducts = [[NSMutableArray alloc] init]; | |
NSMutableArray<SKProductMessage *> *pigeonProducts = [NSMutableArray arrayWithCapacity: skProducts.count]; |
result([FlutterError errorWithCode:@"storekit_getproductrequest_platform_error" | ||
message:error.localizedDescription | ||
details:error.description]); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This return
got lost. You'll want to short circuit any of the following logic. In order to do that you'll have to call the completion handler then return.
message:@"Failed to get SKProductResponse in startRequest " | ||
@"call. Error occured on iOS platform" | ||
details:call.arguments]); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
[self.paymentQueueHandler presentCodeRedemptionSheet]; | ||
result(nil); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just want to call out how these calls have disappears now. In the past, failing to call these created bugs, you've eliminated that risk now 👍
} | ||
|
||
@visibleForTesting | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
@@ -383,6 +550,53 @@ class SKProductWrapper { | |||
subscriptionPeriod, | |||
introductoryPrice, | |||
discounts); | |||
|
|||
/// Convert from [SKProductMessage] to [SKProductWrapper] | |||
static SKProductWrapper convertFromPigeon(SKProductMessage msg) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No action required: These are all a pain. I guess if pigeon had been used from day one, the generated classes could have been been used. We also talked about letting pigeon use existing classes too. That would have really helped here.
|
||
enum SKSubscriptionPeriodUnitMessage { | ||
day, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove newlines please
|
||
@override | ||
void presentCodeRedemptionSheet() { | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return; |
} | ||
|
||
/// Convert from [SKProductWrapper] to [SKProductMessage] | ||
static SKProductMessage convertToPigeon(SKProductWrapper wrapper) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do all of these have tests?
@@ -470,7 +470,7 @@ + (nullable SKProductMessage *)convertProductToPigeon:(nullable SKProduct *)prod | |||
|
|||
NSArray<SKProductDiscount *> *skProductDiscounts = product.discounts; | |||
NSMutableArray<SKProductDiscountMessage *> *pigeonProductDiscounts = | |||
[[NSMutableArray alloc] init]; | |||
[[NSMutableArray arrayWithCapacity:skProductDiscounts.count] init]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't want to call init
when using arrayWithCapacity:
, that's already taken care for you. You just need that when you are using alloc
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh oopsies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Don't forget to manually test it with the example app before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just briefly skimmed through since Aaron already reviewed it
@@ -307,6 +307,10 @@ + (nullable SKPaymentTransactionMessage *)convertTransactionToPigeon: | |||
} | |||
|
|||
+ (nullable SKErrorMessage *)convertSKErrorToPigeon:(NSError *)error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: mark error
as nullable
[self presentCodeRedemptionSheet:call result:result]; | ||
#endif | ||
} else if ([@"-[InAppPurchasePlugin retrieveReceiptData:result:]" isEqualToString:call.method]) { | ||
if ([@"-[InAppPurchasePlugin retrieveReceiptData:result:]" isEqualToString:call.method]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is probably not related to your PR - is this format iOS only? It's very objc-specific. do we intend to change that after migrating to swift?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this entire code block/fcn will be removed after the pigeon migration so it should be fine
details:e.description]); | ||
*error = [FlutterError errorWithCode:@"storekit_finish_transaction_exception" | ||
message:e.name | ||
details:e.description]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is this error used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all generated pigeon functions have like an extra "error" param, I think it gets passed back to the dart side automatically
I'm not sure why that CI step keeps failing, it's an infra failure so it's likely not caused by this PR. You can try updating your branch by merging in main or rebasing against main. |
…o iap_pigeon_part_2
…ansactions(), presentCodeRedemptionSheet() to pigeon (flutter/packages#6032)
flutter/packages@0a69259...9385bbb 2024-02-13 louisehsu@google.com Convert startProductRequest(), finishTransaction(), restoreTransactions(), presentCodeRedemptionSheet() to pigeon (flutter/packages#6032) 2024-02-13 49699333+dependabot[bot]@users.noreply.github.com [in_app_pur]: Bump org.json:json from 20231013 to 20240205 in /packages/in_app_purchase/in_app_purchase/example/android/app (flutter/packages#6096) 2024-02-12 stuartmorgan@google.com [local_auth] Rename iOS classes (flutter/packages#6108) 2024-02-12 jakubwalusiak@gmail.com [video_player_android] Handle BehindLiveWindowException (flutter/packages#5869) 2024-02-12 reidbaker@google.com [in_app_purchase] Add alternative billing apis for android (flutter/packages#6056) 2024-02-12 stuartmorgan@google.com [webview_flutter] Update compileSdk to 34 (flutter/packages#6106) 2024-02-12 37270954+foxtrotravi@users.noreply.github.com [cupertino_icons] Add example to cupertino icons (flutter/packages#5312) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC flutter-ecosystem@google.com,rmistry@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…ns(), presentCodeRedemptionSheet() to pigeon (flutter#6032) Part 2 of flutter/flutter#117910 This PR converts startProductRequest(), finishTransaction(), restoreTransactions(), presentCodeRedemptionSheet() to pigeon, as well as add all remaining converts to and from pigeons for SK objects. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] All existing and new tests are passing.
Part 2 of flutter/flutter#117910
This PR converts startProductRequest(), finishTransaction(), restoreTransactions(), presentCodeRedemptionSheet() to pigeon, as well as add all remaining converts to and from pigeons for SK objects.
Pre-launch Checklist
///
).