Repository: flutter
Issue: [In-App-Purchase][iOS] Purchase Stream Not Triggering for Purchased Status in TestFlight on iOS on Subscription
Labels: platform-ios,p: in_app_purchase,package,a: production,P2,team-ios,triaged-ios

### Steps to reproduce


1. Set up a listener for the purchase stream:  
   ```dart
   InAppPurchase.instance.purchaseStream.listen(_listenToPurchaseUpdated);
   ```  
2. Deploy the app to TestFlight on iOS.  
3. Purchase a subscription in the app.  
4. Observe the following:  
   - The purchase stream is triggered correctly for the **Pending** state.  
5. Complete the subscription purchase.  
6. Check if the purchase stream is triggered for the **Purchased** status.  

### Notes:  
- The issue occurs only for **subscriptions**, not regular in-app purchases.  
- This behavior is observed **only in TestFlight**; it works correctly during development.  

### Expected results

The purchase stream (`InAppPurchase.instance.purchaseStream`) should be triggered with the **Purchased** status after completing a subscription purchase.

### Actual results

The purchase stream (`InAppPurchase.instance.purchaseStream`) is **not triggered** with the **Purchased** status after completing a subscription purchase. 

However, it works correctly for consumable purchases.

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'dart:async';
import 'dart:developer';

import 'package:in_app_purchase/in_app_purchase.dart';

class InAppPurchaseService {
  late StreamSubscription<List<PurchaseDetails>> _subscription;

  void init() {
    log("init is called on InAppPurchaseService");
    final instance = InAppPurchase.instance;

    final Stream<List<PurchaseDetails>> purchaseUpdated =
        instance.purchaseStream;
    _subscription = purchaseUpdated.listen(
      _listenToPurchaseUpdated,
    );
  }

  void _listenToPurchaseUpdated(List<PurchaseDetails> purchaseDetailsList) {
    purchaseDetailsList.forEach((PurchaseDetails purchaseDetails) async {
      if (purchaseDetails.status == PurchaseStatus.error) {
      } else if (purchaseDetails.status == PurchaseStatus.pending) {
        /// This get called
      } else if (purchaseDetails.status == PurchaseStatus.purchased) {
        /// This is not called for subscription
        ///
        /// Handle verification and consume the purchase
      } else if (purchaseDetails.status == PurchaseStatus.canceled) {
      } else if (purchaseDetails.status == PurchaseStatus.restored) {}
    });
  }
}

/// From the UI we will make purchase using
 await InAppPurchase.instance.buyNonConsumable(
     purchaseParam: PurchaseParam(
     productDetails: _selectedProduct!,
   ),
 );


```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

[Upload media here]

</details>


### Logs

<details open><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.22.0, on macOS 15.2 24C101 darwin-arm64, locale en-NP)
    • Flutter version 3.22.0 on channel stable at /Users/pawanacharya/fvm/versions/3.22.0
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5dcb86f68f (8 months ago), 2024-05-09 07:39:20 -0500
    • Engine revision f6344b75dc
    • Dart version 3.4.0
    • DevTools version 2.34.3

[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/pawanacharya/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_SDK_ROOT = /Users/pawanacharya/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses

[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16B40
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.3)
    • 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.10+0-17.0.10b1087.21-11572160)

[✓] IntelliJ IDEA Ultimate Edition (version 2022.1.4)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 74.0.1
    • Dart plugin version 221.6103.1

[✓] VS Code (version 1.76.2)
    • VS Code at /Users/pawanacharya/Desktop/Visual Studio Code.app/Contents
    • Flutter extension version 3.92.0

[✓] Connected device (4 available)
    • Pawan’s iPhone (mobile)         • 00008120-001E49E4210BC01E • ios            • iOS 18.2 22C152
    • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 15.2 24C101 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 15.2 24C101 darwin-arm64
    • Chrome (web)                    • chrome                    • web-javascript • Google Chrome 131.0.6778.205

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

```

</details>