Replies: 2 comments
-
|
Thanks for asking about these fields! Let me explain what they are and how they relate to the introductory offer workflow. What These Fields RepresentThese fields in
How They Are PopulatedThese fields are populated by the OpenIAP Apple library from StoreKit's Relationship to subscriptionInfoIOSThese fields are legacy/convenience fields that provide the same information as: product.subscriptionInfoIOS?.introductoryOfferThe Usage ExampleRecommended approach (using subscriptionInfoIOS): const subscription = subscriptions.find((s) => s.id === 'premium_monthly');
if (subscription?.subscriptionInfoIOS?.introductoryOffer) {
const offer = subscription.subscriptionInfoIOS.introductoryOffer;
switch (offer.paymentMode) {
case 'free-trial':
console.log(`${offer.periodCount} ${offer.period.unit.toLowerCase()}(s) free trial`);
break;
case 'pay-as-you-go':
console.log(`${offer.displayPrice} for ${offer.periodCount} period(s)`);
break;
case 'pay-up-front':
console.log(`${offer.displayPrice} upfront for ${offer.periodCount} period(s)`);
break;
}
}Legacy approach (using the direct fields you mentioned): const subscription = subscriptions.find((s) => s.id === 'premium_monthly');
if (subscription?.introductoryPriceIOS) {
console.log('Intro price:', subscription.introductoryPriceIOS);
console.log('Payment mode:', subscription.introductoryPricePaymentModeIOS);
console.log('Number of periods:', subscription.introductoryPriceNumberOfPeriodsIOS);
}Important Notes
For a complete guide on working with subscription offers, see: https://docs.expo-iap.dev/docs/guides/subscription-offers Let me know if you have any other questions! |
Beta Was this translation helpful? Give feedback.
-
|
These fields are automatically populated from StoreKit when you call Recommended approach: const offer = subscription?.subscriptionInfoIOS?.introductoryOffer;
if (offer) {
console.log(offer.displayPrice, offer.paymentMode, offer.periodCount);
}Using the direct fields: if (subscription?.introductoryPriceIOS) {
console.log(subscription.introductoryPriceIOS);
console.log(subscription.introductoryPricePaymentModeIOS);
}Note: iOS automatically applies introductory offers for eligible users - no extra code needed for purchase. These fields are for display purposes only. See: https://hyochan.github.io/expo-iap/guides/subscription-offers#introductory-offers |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
There are some undocumented fields on ProductSubscriptionIOS, that seams like may be used to simplify introductory offer workflow. These fields are: introductoryPriceAsAmountIOS, introductoryPriceIOS, introductoryPriceNumberOfPeriodsIOS, introductoryPricePaymentModeIOS, introductoryPriceSubscriptionPeriodIOS.
How they are populated, and can be used for introductory offer workflow on iOS?
Beta Was this translation helpful? Give feedback.
All reactions