v14.1.0 - Type System Improvements & API Enhancements
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 fromPromise<boolean>
toPromise<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 platformsisAutoRenewing: 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
anddeferred
states are handled through separate flows. - Android: Supports
pending
(awaiting payment),purchased
(completed), andunknown
(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.