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
gaaclarke
left a comment
There was a problem hiding this comment.
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.
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.
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.
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; |
| #if TARGET_OS_IOS | ||
| - (void)presentCodeRedemptionSheet:(FlutterMethodCall *)call result:(FlutterResult)result { | ||
| [self.paymentQueueHandler presentCodeRedemptionSheet]; | ||
| result(nil); |
There was a problem hiding this comment.
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 | ||
|
|
| discounts); | ||
|
|
||
| /// Convert from [SKProductMessage] to [SKProductWrapper] | ||
| static SKProductWrapper convertFromPigeon(SKProductMessage msg) { |
There was a problem hiding this comment.
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, | ||
|
|
|
|
||
| @override | ||
| void presentCodeRedemptionSheet() { | ||
| return; |
| } | ||
|
|
||
| /// Convert from [SKProductWrapper] to [SKProductMessage] | ||
| static SKProductMessage convertToPigeon(SKProductWrapper wrapper) { |
| NSArray<SKProductDiscount *> *skProductDiscounts = product.discounts; | ||
| NSMutableArray<SKProductDiscountMessage *> *pigeonProductDiscounts = | ||
| [[NSMutableArray alloc] init]; | ||
| [[NSMutableArray arrayWithCapacity:skProductDiscounts.count] init]; |
There was a problem hiding this comment.
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.
gaaclarke
left a comment
There was a problem hiding this comment.
LGTM! Don't forget to manually test it with the example app before merging.
hellohuanlin
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
where is this error used?
There was a problem hiding this comment.
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
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
///).