Skip to content

ProductSubscriptionIOS.subscriptionOffers is always null #616

@FeanorD

Description

@FeanorD

🚨 MANDATORY PRE-SUBMISSION CHECKLIST

✅ Checklist

  • Have you run the example/ project?
    • Most usage patterns are demonstrated in the example
    • Example path: /example/lib/main.dart
    • Did you reference the example code for your implementation?
  • Have you read the README documentation?
  • Have you searched existing issues for similar questions?

📱 Example Project Reference

Example Code Review

  • I've checked the example's initialization code
  • I've checked the example's purchase flow
  • I've checked the example's error handling
  • I've implemented the same as the example but it doesn't work

❓ Your Question

What would you like to know? Please be specific.

In ProductSubscriptionIOS implementation, the documentation comments say that discountsIOS is deprecated and subscriptionOffers should be used instead.

💻 Current Code

/lib/types.dart

...
/// @deprecated Use subscriptionOffers instead for cross-platform compatibility.
  final List<DiscountIOS>? discountsIOS;
...
/// @deprecated Use subscriptionOffers instead for cross-platform compatibility.
  final SubscriptionInfoIOS? subscriptionInfoIOS;

However, in parseProductFromNative() implementation, the subscriptionInfoIOS is missing in ProductSubscriptionIOS instantiation.

/lib/flutter_inapp_purchase.dart

gentype.ProductCommon parseProductFromNative(
  Map<String, dynamic> json,
  String type, {
  required bool fallbackIsIOS,
}) {
...

  if (productType == gentype.ProductType.Subs) {
    if (platform == gentype.IapPlatform.IOS) {
      return gentype.ProductSubscriptionIOS(
        currency: currency,
        description: description,
        displayNameIOS: json['displayNameIOS']?.toString() ?? title,
        displayPrice: displayPrice,
        id: productId,
        isFamilyShareableIOS: json['isFamilyShareableIOS'] as bool? ?? false,
        jsonRepresentationIOS:
            json['jsonRepresentationIOS']?.toString() ?? '{}',
        platform: platform,
        title: title,
        type: productType,
        typeIOS: _parseProductTypeIOS(json['typeIOS']?.toString()),
        debugDescription: json['debugDescription']?.toString(),
        // Only discountsIOS is provided
        discountsIOS: _parseDiscountsIOS(
          json['discountsIOS'] ?? json['discounts'],
        ),
        displayName: json['displayName']?.toString(),
        introductoryPriceAsAmountIOS:
            json['introductoryPriceAsAmountIOS']?.toString(),
        introductoryPriceIOS: json['introductoryPriceIOS']?.toString(),
        introductoryPriceNumberOfPeriodsIOS:
            json['introductoryPriceNumberOfPeriodsIOS']?.toString(),
        introductoryPricePaymentModeIOS: _parsePaymentMode(
          json['introductoryPricePaymentModeIOS'],
        ),
        introductoryPriceSubscriptionPeriodIOS: _parseSubscriptionPeriod(
          json['introductoryPriceSubscriptionPeriodIOS'],
        ),
        price: priceValue,
        subscriptionInfoIOS: _parseSubscriptionInfoIOS(
          json['subscriptionInfoIOS'] ?? json['subscription'],
        ),
        subscriptionPeriodNumberIOS:
            json['subscriptionPeriodNumberIOS']?.toString(),
        subscriptionPeriodUnitIOS: _parseSubscriptionPeriod(
          json['subscriptionPeriodUnitIOS'],
        ),
      );
    }
...
  }
...
}
// Paste your code here

📱 Environment

Package version:

  • flutter_inapp_purchase: ^8.2.6

Platform:

  • iOS
  • Android

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions