Flutter iOS inapp subscription

Summary

The issue at hand is related to InApp subscription products not being displayed on a specific tester’s device, despite the subscription working fine on development IPA’s and IPA’s distributed through Testflight as internal testers. The key points to note are:

  • The issue occurs on a device with a different country and iOS version
  • The subscription products are not being displayed, but the subscription itself is working fine in other scenarios
  • The app has not yet been submitted for review

Root Cause

The root cause of this issue is likely due to one of the following:

  • Incorrect configuration of the InApp subscription products
  • Insufficient testing on different devices and regions
  • Issues with the _iap.queryProductDetails function
  • Localization issues with the Subscription Group and Product Listing

Why This Happens in Real Systems

This issue can occur in real systems due to:

  • Differences in device and region configurations
  • Inadequate testing on various devices and regions
  • Complexity of InApp subscription configurations and settings
  • Changes in iOS versions and their impact on InApp purchases

Real-World Impact

The real-world impact of this issue includes:

  • Loss of revenue due to non-functional InApp subscriptions
  • Negative user experience resulting from non-displayed subscription products
  • Difficulty in debugging and resolving the issue due to its complexity
  • Delays in app release due to the need to resolve the issue before submission

Example or Code

Future initializeInAppPurchase() async {
  _isPurchaseTapped = false;
  _isPurchaseSuccessShown = false;
  try {
    _subscription ??= _iap.purchaseStream.listen(
      _listenToPurchaseUpdated,
      onDone: () async {
        await _subscription?.cancel();
      },
      onError: (error) async {
        await _subscription?.cancel();
      },
    );
    final available = await _iap.isAvailable();
    isAvailable.value = available;
    if (!available) {
      return;
    }
    final response = await _iap.queryProductDetails(_productIds);
    if (response.error != null) {
      log('IAP query error: ${response.error}');
      return;
    }
    products.assignAll(
      response.productDetails.where(
        (productDetail) => productDetail.rawPrice > 0,
      ),
    );
    await fetchUserSubscription();
  } catch (e) {
    log(e.toString());
  } finally {
    _isLoading.value = false;
  }
}

How Senior Engineers Fix It

Senior engineers can fix this issue by:

  • Verifying the InApp subscription configuration and settings
  • Testing the app on various devices and regions
  • Debugging the _iap.queryProductDetails function to ensure it is working correctly
  • Checking for localization issues with the Subscription Group and Product Listing
  • Ensuring the app is properly configured for InApp purchases

Why Juniors Miss It

Junior engineers may miss this issue due to:

  • Lack of experience with InApp subscription configurations and settings
  • Insufficient testing on various devices and regions
  • Limited understanding of the _iap.queryProductDetails function and its potential issues
  • Overlooking localization issues with the Subscription Group and Product Listing
  • Inadequate debugging and troubleshooting skills

Leave a Comment