-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[in_app_purchase_storekit] Add support for purchase and transactions #7574
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
Conversation
@@ -27,6 +27,10 @@ public class InAppPurchasePlugin: NSObject, FlutterPlugin, InAppPurchaseAPI { | |||
// This property is optional, as it requires self to exist to be initialized. | |||
public var paymentQueueHandler: FLTPaymentQueueHandlerProtocol? | |||
|
|||
// This should be an Task, but Task is on available >= iOS 13 | |||
var updateListenerTask: Any? |
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.
can you try out that getter trick discussed yesterday?
packages/in_app_purchase/in_app_purchase_storekit/darwin/Classes/InAppPurchasePlugin.swift
Outdated
Show resolved
Hide resolved
..._app_purchase/in_app_purchase_storekit/darwin/Classes/StoreKit2/InAppPurchaseStoreKit2.swift
Outdated
Show resolved
Hide resolved
..._app_purchase/in_app_purchase_storekit/darwin/Classes/StoreKit2/InAppPurchaseStoreKit2.swift
Outdated
Show resolved
Hide resolved
} | ||
case .pending: | ||
completion( | ||
.failure( |
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.
reduce indentation by combining these
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.
the formatter uncombines these
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.
strange. it's clearly less than 100 characters. how's your code like before the formatter?
@MainActor in | ||
do { | ||
let transactionsMsgs = await rawTransactions().map { | ||
$0.convertToPigeon() |
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: use keypath
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.
"Keypath can’t be used on instance methods"
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 you are right
..._app_purchase/in_app_purchase_storekit/darwin/Classes/StoreKit2/InAppPurchaseStoreKit2.swift
Outdated
Show resolved
Hide resolved
} | ||
|
||
/// Helper function to cast updateListenerTask to a task | ||
func getUpdateListenerTask() -> Task<(), Never> { |
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.
can you use a getter (rather than a function) in the class definition (rather than extension). And make updateListenerTask
private.
..._purchase/in_app_purchase_storekit/example/shared/RunnerTests/StoreKit2TranslatorTests.swift
Outdated
Show resolved
Hide resolved
@testable import in_app_purchase_storekit | ||
|
||
@available(iOS 15.0, macOS 12.0, *) | ||
class StoreKit2TranslatorTests: XCTestCase { |
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.
final class
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 after the nits
private var _updateListenerTask: Any? | ||
|
||
@available(iOS 13.0, *) | ||
var getListenerTaskAsTask: Task<(), Never> { |
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 can change it in next PR - getter shouldn't have a get
prefix. It should be just var updateListenerTask: Task<(), Never>
…actions" (#7810) Reverts #7574 This is failing for `stable` (which only runs in post-submit). See https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8734714858533469745/+/u/Run_package_tests/native_test/stdout for errors.
flutter/packages@bb00d34...8fbf4cd 2024-10-08 engine-flutter-autoroll@skia.org Manual roll Flutter from 0975e61 to ec2e12b (54 revisions) (flutter/packages#7815) 2024-10-08 engine-flutter-autoroll@skia.org Manual roll Flutter from 6bba08c to 0975e61 (1 revision) (flutter/packages#7814) 2024-10-08 49699333+dependabot[bot]@users.noreply.github.com Bump actions/checkout from 4.1.7 to 4.2.1 (flutter/packages#7813) 2024-10-08 10687576+bparrishMines@users.noreply.github.com [interactive_media_ads] Adds remaining methods for internal wrapper of the iOS native `IMAAdsRenderingSettings` (flutter/packages#7745) 2024-10-08 stuartmorgan@google.com [url_launcher] Remove incorrect SMS instructions (flutter/packages#7807) 2024-10-08 engine-flutter-autoroll@skia.org Manual roll Flutter from ead6b0d to 6bba08c (37 revisions) (flutter/packages#7809) 2024-10-07 jtanium@gmail.com [webview_flutter_wkwebview] Support NTLM for authentication (flutter/packages#7670) 2024-10-07 stuartmorgan@google.com Revert "[in_app_purchase_storekit] Add support for purchase and transactions" (flutter/packages#7810) 2024-10-07 louisehsu@google.com [in_app_purchase_storekit] Add support for purchase and transactions (flutter/packages#7574) 2024-10-07 engine-flutter-autoroll@skia.org Manual roll Flutter from fa402c8 to ead6b0d (14 revisions) (flutter/packages#7806) 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 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
…7574 (#7812) This PR contains the preliminary implementations for handling [purchases](https://developer.apple.com/documentation/storekit/product/3791971-purchase) and [transactions](https://developer.apple.com/documentation/storekit/transaction) Of note, as of StoreKit 2, the [result of a call to a purchase will only return a Transaction](https://developer.apple.com/documentation/storekit/product/purchaseresult) when the purchase is successful. If the status of purchase is pending, or cancelled, nothing will be returned. This is in contrast to StoreKit 1, where developers could check the state of a Transaction with [TransactionState](https://developer.apple.com/documentation/storekit/skpaymenttransaction/1411275-transactionstate). This means that migrating to StoreKit 2 will require developers to update their handling of transactions accordingly. Relands #7574
…actions #7574" (#7886) Reverts #7812 See #7812 (comment)
…7887) This PR contains the preliminary implementations for handling [purchases](https://developer.apple.com/documentation/storekit/product/3791971-purchase) and [transactions](https://developer.apple.com/documentation/storekit/transaction) Of note, as of StoreKit 2, the [result of a call to a purchase will only return a Transaction](https://developer.apple.com/documentation/storekit/product/purchaseresult) when the purchase is successful. If the status of purchase is pending, or cancelled, nothing will be returned. This is in contrast to StoreKit 1, where developers could check the state of a Transaction with [TransactionState](https://developer.apple.com/documentation/storekit/skpaymenttransaction/1411275-transactionstate). This means that migrating to StoreKit 2 will require developers to update their handling of transactions accordingly. Relands #7574
This PR contains the preliminary implementations for handling purchases and transactions
Of note, as of StoreKit 2, the result of a call to a purchase will only return a Transaction when the purchase is successful. If the status of purchase is pending, or cancelled, nothing will be returned.
This is in contrast to StoreKit 1, where developers could check the state of a Transaction with TransactionState. This means that migrating to StoreKit 2 will require developers to update their handling of transactions accordingly.
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style, or this PR is exempt from CHANGELOG changes.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.