dooboolab-community / react-native-iap

In App Purchase module for React Native!
https://react-native-iap.dooboolab.com
MIT License
2.75k stars 632 forks source link

[IOS] Subscribing promoted/introductory subscription #1102

Closed lc3t35 closed 3 years ago

lc3t35 commented 3 years ago

Version of react-native-iap :

4.5.2

Version of react-native :

ejected expo SDK38 0.62.2

Platforms you faced the error :

IOS only

Expected behavior

As already mentioned by closed issue #978 , it is not clearly stated if it is possible or not and how one can activate promoted subscriptions offer (not product, but subscription based offer). Reference : https://developer.apple.com/app-store/subscriptions/#offer-types

_Note for Android : even if the topic is iOS here, for Android, it's easy to setup on Play Store an intro offer (free trial period), it is well activated with iap without any additional configuration. 👍 _

Actual behavior

When I list subscriptions, I have in the record a discounts entry including an offer that matches the one I've setup in AppStoreConnect : here an annual subscription with 1 month of trial

[ { 
    productId: 'com.XXX.sdk38.annual',
    subscriptionPeriodUnitIOS: 'YEAR',
    description: 'Activate Premium features on XXX',
    introductoryPrice: '',
    title: 'Annual',
    introductoryPriceSubscriptionPeriodIOS: '',
    introductoryPriceNumberOfPeriodsIOS: '',
    discounts: 
     [ { localizedPrice: '€0,00',
         numberOfPeriods: '1',
         type: 'SUBSCRIPTION',
         identifier: 'com.XXX.sdk38.tryannual',
         paymentMode: 'FREETRIAL',
         price: '0',
         subscriptionPeriod: 'MONTH' } ],
    type: 'Do not use this. It returned sub only before',
    localizedPrice: '€54,99',
    introductoryPricePaymentModeIOS: '',
    price: '54.99',
    currency: 'EUR',
    subscriptionPeriodNumberIOS: '1'
 }

If I try to activate the subscription with "com.XXX.sdk38.tryannual", it tells me that productID does not exists. If I activate with "com.XXX.sdk38.annual", it buys the subscription but without the trial period. If I setup an introductory offer and activate with "com.XXX.sdk38.annual", it buys the subscription with the trial period.

Tested environment :

Real device iPhone 6S 13.x, sandbox account

Steps to reproduce the behavior

Ouch ! Maybe it just need a documentation update or clarification ;)

rimselis commented 3 years ago

Was wondering the same thing, I have 2 renewable subscriptions with introductory offer and discount (launch discount + free trial).

I noticed there is a method available to purchase with offers: export declare const requestPurchaseWithOfferIOS: (sku: string, forUser: string, withOffer: Apple.PaymentDiscount) => Promise<void>;

But withOffer requires some kind of signing:

 * @param {Apple.PaymentDiscount} withOffer The offer information
 * @param {string} withOffer.identifier The offer identifier
 * @param {string} withOffer.keyIdentifier Key identifier that it uses to generate the signature
 * @param {string} withOffer.nonce An UUID returned from the server
 * @param {string} withOffer.signature The actual signature returned from the server
 * @param {number} withOffer.timestamp The timestamp of the signature
doyomay commented 3 years ago

I was having the same issue and for the "withOffer" object you need to get your signed from your backend.

first, you need to follow this steps to get your key and privatekey https://help.apple.com/app-store-connect/#/dev689c93225

and when you get this values, you need to follow this tutorial, is an example with nodejs at the backend

https://developer.apple.com/documentation/storekit/in-app_purchase/subscriptions_and_offers/generating_a_subscription_offer_signature_on_the_server

cheers.

stale[bot] commented 3 years ago

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

stale[bot] commented 3 years ago

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

stale[bot] commented 3 years ago

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.