Skip to main content

v14.1.0 - Type System Improvements & API Enhancements

ยท 3 min read
Hyo
React Native IAP Maintainer

We're excited to announce React Native IAP 14.1.0 with significant type system improvements and API enhancements! ๐Ÿš€

โš ๏ธ Note: This release contains breaking changes. Please review the migration guide carefully.

โš ๏ธ Breaking Changesโ€‹

1. Platform-Specific Field Namingโ€‹

All platform-specific fields now have platform suffixes for clarity.

2. API Method Changesโ€‹

  • showManageSubscriptionsIOS() return type changed from Promise<boolean> to Promise<NitroPurchase[]>
  • validateReceipt() method signature has been updated

3. Type System Updatesโ€‹

Several type definitions have been restructured for better type safety.

What's New in v14.1.0โ€‹

๐ŸŽฏ Enhanced Type Systemโ€‹

Platform-Specific Field Naming Conventionโ€‹

All platform-specific fields now follow a consistent naming pattern with platform suffixes:

iOS fields now end with IOS:

  • isFamilyShareable โ†’ isFamilyShareableIOS
  • jsonRepresentation โ†’ jsonRepresentationIOS
  • New: typeIOS for detailed iOS product types

Android fields now end with Android:

  • originalPrice โ†’ originalPriceAndroid
  • introductoryPriceValue โ†’ introductoryPriceValueAndroid
  • subscriptionPeriod โ†’ subscriptionPeriodAndroid

This change makes it immediately clear which fields are platform-specific, improving code maintainability and reducing confusion.

๐Ÿ”„ Common Purchase Fieldsโ€‹

Added new common fields to the PurchaseCommon type for better cross-platform consistency:

  • quantity: number - Purchase quantity (defaults to 1)
  • purchaseState: PurchaseState - Unified purchase state across platforms
  • isAutoRenewing: boolean - Auto-renewal status for subscriptions

๐Ÿ“ฑ iOS Product Typesโ€‹

Introduced ProductTypeIOS enum for more granular iOS product categorization:

enum ProductTypeIOS {
consumable = 'consumable',
nonConsumable = 'nonConsumable',
autoRenewableSubscription = 'autoRenewableSubscription',
nonRenewingSubscription = 'nonRenewingSubscription',
}

๐Ÿ”„ Purchase Statesโ€‹

New unified PurchaseState enum for consistent purchase status handling:

enum PurchaseState {
pending = 'pending', // Android: waiting for payment confirmation
purchased = 'purchased', // Both: successfully purchased
failed = 'failed', // Both: purchase failed/revoked
restored = 'restored', // iOS only: restored from previous purchase
deferred = 'deferred', // iOS only: waiting for parental approval
unknown = 'unknown', // Both: unspecified state
}

Platform Notes:

  • iOS: StoreKit 2 primarily uses purchased state for verified transactions. restored and deferred states are handled through separate flows.
  • Android: Supports pending (awaiting payment), purchased (completed), and unknown (unspecified) states directly from the Play Billing Library.

๐Ÿ“‹ API Method Updatesโ€‹

showManageSubscriptionsIOS()โ€‹

The showManageSubscriptionsIOS() method now returns updated subscription information:

// Before: Promise<boolean>
// Now: Promise<NitroPurchase[]>
const updatedSubscriptions = await showManageSubscriptionsIOS();

This allows you to get real-time subscription status updates after users modify their subscriptions.

Migration Guideโ€‹

Updating Type Referencesโ€‹

If you're accessing platform-specific fields, update your code:

// Before
if (product.isFamilyShareable) { }
if (product.originalPrice) { }

// After
if (product.isFamilyShareableIOS) { }
if (product.originalPriceAndroid) { }

Using New Purchase Statesโ€‹

import { PurchaseState } from 'react-native-iap';

if (purchase.purchaseState === PurchaseState.purchased) {
// Handle successful purchase
} else if (purchase.purchaseState === PurchaseState.pending) {
// Handle pending purchase
}

Handling showManageSubscriptionsIOS Responseโ€‹

// Before
const success = await showManageSubscriptionsIOS();
if (success) {
// Refresh subscriptions manually
}

// After
const updatedSubscriptions = await showManageSubscriptionsIOS();
// Use the returned subscription data directly
updatedSubscriptions.forEach(sub => {
console.log('Updated subscription:', sub.productId, sub.isAutoRenewing);
});

Benefitsโ€‹

โœ… Improved Type Safetyโ€‹

Platform-specific fields are now clearly marked, reducing runtime errors from accessing wrong platform fields.

โœ… Better Developer Experienceโ€‹

Consistent naming conventions make the API more predictable and easier to use.

โœ… Enhanced Cross-Platform Supportโ€‹

Common fields like purchaseState and isAutoRenewing provide unified interfaces across platforms.

โœ… More Detailed Informationโ€‹

New enums and return types provide richer information about products and purchases.

Upgradingโ€‹

npm install react-native-iap react-native-nitro-modules

Communityโ€‹

Thank you to all contributors who helped make this release possible!

For questions or issues, please visit our GitHub repository.