Skip to content

[in_app_purchase_storekit] StoreKit2 call completePurchase() await forever #160148

Closed
flutter/packages
#8324

Description

@codingiran

Steps to reproduce

  1. enable Storekit2
InAppPurchaseStoreKitPlatform.enableStoreKit2();
  1. make a product purchase and get a PurchaseDetails in _listenToPurchaseUpdate() callback
 Future<void> _handleReportedPurchaseState(PurchaseDetails purchaseDetails) async {
      ...
      ...

      if (purchaseDetails.pendingCompletePurchase) {
        await _iapStoreKitPlatform.completePurchase(purchaseDetails);
      }
    }
  }
  1. You will find completePurchase() never finish and await is forever 😅

Expected results

await completePurchase() should return or throw exception

Actual results

await completePurchase() never return forever!

Code sample

Default sample code is enough
https://github.com/flutter/packages/blob/main/packages/in_app_purchase/in_app_purchase_storekit/example/lib/main.dart

Screenshots or Video

No response

Logs

I dig into in_app_purchase_storekit plugin native code, and find some clue about this issue:
Check this code

  /// Wrapper method around StoreKit2's finish() method https://developer.apple.com/documentation/storekit/transaction/3749694-finish
  func finish(id: Int64, completion: @escaping (Result<Void, Error>) -> Void) {
    Task {
      let transaction = try await fetchTransaction(by: UInt64(id))
      if let transaction = transaction {
        await transaction.finish()
      }
    }
  }

⚠️completion closure was never used in finish(id:completion:)⚠️

Flutter Doctor output

Doctor output
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.5, on macOS 15.2 24C101 darwin-arm64, locale en-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.2)
[✓] VS Code (version 1.95.3)
[✓] Connected device (5 available)
    ! Error: Browsing on the local area network for iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources

• No issues found!

Activity

  1. codingiran commented on Dec 12, 2024

    @codingiran
    Author

    @LouiseHsu Please check it, Thanks!

  2. changed the title [-][in_app_purchase_storekit] StoreKit2 call completePurchase() await forver[/-] [+][in_app_purchase_storekit] StoreKit2 call completePurchase() await forever[/+] on Dec 12, 2024
  3. darshankawar commented on Dec 12, 2024

    @darshankawar
    Member
  4. added
    platform-iosiOS applications specifically
    packageflutter/packages repository. See also p: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    team-iosOwned by iOS platform team
    and removed
    in triagePresently being triaged by the triage team
    on Dec 12, 2024
  5. added
    P2Important issues not at the top of the work list
    triaged-iosTriaged by iOS platform team
    on Dec 12, 2024
  6. self-assigned this
    on Dec 12, 2024
  7. added
    r: fixedIssue is closed as already fixed in a newer version
    on Jan 7, 2025
  8. github-actions commented on Jan 21, 2025

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  9. locked as resolved and limited conversation to collaborators on Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listfound in release: 3.24Found to occur in 3.24found in release: 3.27Found to occur in 3.27has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: in_app_purchasePlugin for in-app purchasepackageflutter/packages repository. See also p: labels.platform-iosiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions