Skip to content

[iOS] No event fired on purchase initiation and on cancellation #178292

@MauroGentile

Description

@MauroGentile

What package does this bug report belong to?

in_app_purchase

What target platforms are you seeing this bug on?

iOS

Have you already upgraded your packages?

Yes

Dependency versions

pubspec.lock
  in_app_purchase:
    dependency: "direct main"
    description:
      name: in_app_purchase
      sha256: "5cddd7f463f3bddb1d37a72b95066e840d5822d66291331d7f8f05ce32c24b6c"
      url: "https://pub.dev"
    source: hosted
    version: "3.2.3"
  in_app_purchase_android:
    dependency: "direct main"
    description:
      name: in_app_purchase_android
      sha256: "2d0e2d27b93bd7457526419d7feb07baf5608d733ecf6cdcd2e3b03ea7248915"
      url: "https://pub.dev"
    source: hosted
    version: "0.4.0+6"
  in_app_purchase_platform_interface:
    dependency: transitive
    description:
      name: in_app_purchase_platform_interface
      sha256: "1d353d38251da5b9fea6635c0ebfc6bb17a2d28d0e86ea5e083bf64244f1fb4c"
      url: "https://pub.dev"
    source: hosted
    version: "1.4.0"
  in_app_purchase_storekit:
    dependency: "direct main"
    description:
      name: in_app_purchase_storekit
      sha256: bfdb8d1859b6d19a55aba1046e3a860c631b6e96d36275a358e1caf8b62cfbde
      url: "https://pub.dev"
    source: hosted
    version: "0.4.6+1"

Steps to reproduce

  1. On an iOS device, initiate a purchase by calling InAppPurchase.instance.buy....

  2. Observe: The purchaseStream fires no event.

  3. When the native Apple payment panel appears, cancel the transaction

  4. Observe: The purchaseStream fires no event.

Expected results

I would expect a PurchaseStatus.pending event to be emitted as soon as the payment panel is opened, regardless of whether the user proceeds with the payment.

Also. If the user cancels the purchase (e.g., by dismissing the panel), I would expect the purchaseStream to immediately emit a PurchaseStatus.canceled or PurchaseStatus.error event

Actual results

When a user starts a transaction, PurchaseStatus.pending is not emitted.

In addition, if the user cancels the in-app purchase (e.g., by dismissing the native iOS payment panel), the purchaseStream listener does not receive any update. No event is fired—neither PurchaseStatus.canceled, nor PurchaseStatus.error .

Code sample

Code sample
if (Platform.isIOS) {
      final InAppPurchaseStoreKitPlatformAddition iosPlatformAddition =
          _storeInstance
              .getPlatformAddition<InAppPurchaseStoreKitPlatformAddition>();
      await iosPlatformAddition.setDelegate(IosPaymentQueueDelegate());
    }

    // Set up a listener for purchase updates.
    _purchaseSubscription = _storeInstance.purchaseStream.listen(
      (List<PurchaseDetails> purchaseDetailsList) {
        _listenToPurchases(purchaseDetailsList);
      },
      onDone: () => _purchaseSubscription.cancel(),
      onError: (error) => logError("Purchase listener error: $error"),
    );

}


#################


 Future<void> _listenToPurchases(
      List<PurchaseDetails> purchaseDetailsList) async {
    for (final PurchaseDetails purchaseDetails in purchaseDetailsList) {
      switch (purchaseDetails.status) {
        case PurchaseStatus.pending:
          print("_listenToPurchases Purchase pending...");
          _purchaseUpdateController.add(
            PurchaseUpdate(type: PurchaseEventType.pending),
          );
          break;
        case PurchaseStatus.purchased:
          print("_listenToPurchases Purchase purchased...");
          await _handleSuccessfulPurchase(purchaseDetails);
          break;
        case PurchaseStatus.error:
          print("_listenToPurchases Purchase error...");
          await _handleErrorPurchase(purchaseDetails);
          break;
        case PurchaseStatus.restored:
          print("_listenToPurchases Purchase restored...");
          await _handleRestoredPurchase(purchaseDetails, isRestored: true);
          break;
        case PurchaseStatus.canceled:
          print("_listenToPurchases Purchase canceled...");
          await _handleCancelledPurchase(purchaseDetails);
          break;
      }
    }
  }


Screenshots or Videos

Screenshots / Video demonstration [Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
flutter doctor -v
[✓] Flutter (Channel stable, 3.35.4, on macOS 15.6.1 24G90 darwin-arm64, locale en-GB) [511ms]
    • Flutter version 3.35.4 on channel stable at /Users/mauro/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d693b4b9db (8 weeks ago), 2025-09-16 14:27:41 +0000
    • Engine revision c298091351
    • Dart version 3.9.2
    • DevTools version 2.48.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-lldb-debugging

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [1,655ms]
    • Android SDK at /Users/mauro/Library/Android/sdk
    • Emulator version 34.1.19.0 (build_id 11525734) (CL:N/A)
    • Platform android-36, build-tools 35.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 26.0.1) [2.1s]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 17A400
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [6ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.2) [6ms]
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

Metadata

Metadata

Assignees

No one assigned

    Labels

    r: duplicateIssue is closed as a duplicate of an existing issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions