dooboolab-community / react-native-iap

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

Introductory Offers Not Returning For Subscriptions With StoreKit2 #2471

Closed Shaw-Signaturize closed 7 months ago

Shaw-Signaturize commented 1 year ago

Please use the Discussion board if you want to get some help. Please use issues to report bugs.

Description

When using Ios Storekit1 for retrieving subscriptions, information on the associated introductory offers populates onto the properties

This however does not seem to be the case when using Storekit2 and the properties do not seem to be exposed on any other interface

Expected Behavior

If backwards compatibility is being maintained the properties should populate with the same information

Environment:

To Reproduce Steps to reproduce the behavior:

  1. Create new or modify existing app with IAP configured
  2. Create subscriptions and associated introductory offers in app store connect
  3. Confirm that when using storekit1 the offers return on the correct properties after calling getSubscriptions
  4. Alter setup to use storekit2
  5. No introductory information is returned

[Optional] Additional Context

After debugging it would appear that the issue seems to stem from the function subscriptionSk2Map as it is missing property mapping for the introductory properties.

Suggested change would be the following if it is to maintain backwards compatibility with SubscriptionIOS type

export const subscriptionSk2Map = ({
  id,
  description,
  displayName,
  price,
  displayPrice,
  subscription,
}: ProductSk2): SubscriptionIOS => {
  const prod: SubscriptionIOS = {
    platform: SubscriptionPlatform.ios,
    title: displayName,
    productId: String(id),
    description,
    type: 'subs',
    price: String(price),
    localizedPrice: displayPrice,
    currency: '', // Not available on new API, use localizedPrice instead
    subscriptionPeriodNumberIOS: `${subscription?.subscriptionPeriod?.value}`,
    subscriptionPeriodUnitIOS:
      subscription?.subscriptionPeriod?.unit.toUpperCase() as SubscriptionIosPeriod,
    introductoryPriceAsAmountIOS:
      subscription?.introductoryOffer?.displayPrice,
    introductoryPricePaymentModeIOS:
      subscription?.introductoryOffer?.paymentMode.toUpperCase() as SubscriptionPeriod,
    introductoryPriceNumberOfPeriodsIOS: 
      subscription?.introductoryOffer?.period?.value,
    introductoryPriceSubscriptionPeriodIOS: 
      subscription?.introductoryOffer?.period?.unit as SubscriptionIosPeriod,
  };
  return prod;
};

Im happy to create a PR for this but looking to confirm the intent in terms of structure if it is remaining backwards compatible or if it is to follow more closely with the new IOS structure

usmanabid94 commented 1 year ago

check this link: https://usmanabid477.medium.com/in-app-purchase-integration-in-react-native-app-96c0acd13649

Shaw-Signaturize commented 1 year ago

@usmanabid94 Sorry I think there might be a misunderstanding. The article linked only showed a basic setup of IAP.

The issue relates specifically to the introductory offers returning in the JS. In store kit 1 this all returns correctly and is mapped to the JS correctly. In store kit 2 the native object also gets the information but is never mapped to the JS. All my proposed modification does is add the properties to the mapping function in line with the current typescript.

My main query here is one of clarification from the maintainers as the two IOS implementations for introductory offers have quite a significant interface difference.

caoyongfeng0214 commented 10 months ago

same here. where is subscriptionSk2Map ? how to fix it ?

Shaw-Signaturize commented 10 months ago

subscriptionSk2Map

I ended up forking the repo and making a package override as i heard nothing from the maintainers on the issue. If you clone the repo and search for subscriptionSk2Map you should find the function definition. Replace with what I pasted above and it should start working.

As a word of caution i forked from 12.10.5 and there seems to be a few more patches since then.

RashVenkat6795 commented 10 months ago

subscriptionSk2Map

I ended up forking the repo and making a package override as i heard nothing from the maintainers on the issue. If you clone the repo and search for subscriptionSk2Map you should find the function definition. Replace with what I pasted above and it should start working.

As a word of caution i forked from 12.10.5 and there seems to be a few more patches since then.

I tried to add this and check It works on the debug mode, but when tried to push the app on TestFlight to test... the free trial details doesn't show up on the pop up.

Any idea on this? @Shaw-Signaturize @andresesfm

Shaw-Signaturize commented 10 months ago

subscriptionSk2Map

I ended up forking the repo and making a package override as i heard nothing from the maintainers on the issue. If you clone the repo and search for subscriptionSk2Map you should find the function definition. Replace with what I pasted above and it should start working. As a word of caution i forked from 12.10.5 and there seems to be a few more patches since then.

I tried to add this and check It works on the debug mode, but when tried to push the app on TestFlight to test... the free trial details doesn't show up on the pop up.

Any idea on this? @Shaw-Signaturize @andresesfm

I had a similar issue as our build process runs the npm install and pod install before bundling to testflight. My best guess would be to check your node_modules and check that the version being used is your custom version and it hasnt pulled the one off the public npm.

I think as this problem seems to be hitting a few people I will try and get the change bundled into a PR and get feedback that way

RashVenkat6795 commented 10 months ago

@Shaw-Signaturize Sure, that would really help Since it's the most high priority use case that anyone would want to get it implemented and working.

Looking forward to your PR

Shaw-Signaturize commented 10 months ago

@Shaw-Signaturize Sure, that would really help Since it's the most high priority use case that anyone would want to get it implemented and working.

Looking forward to your PR

Cool ill see if i can get to it early next week

RashVenkat6795 commented 10 months ago

@Shaw-Signaturize Were you able to create PR for this ?

RashVenkat6795 commented 9 months ago

@Shaw-Signaturize any update on this ? Looking forward to this PR

Shaw-Signaturize commented 9 months ago

@RashVenkat6795 Sorry about the delay. Thought i was going to have availability that week and then other things got in the way. PR should be up now

PR: https://github.com/dooboolab-community/react-native-iap/pull/2630

RashVenkat6795 commented 8 months ago

@Shaw-Signaturize thanks for this PR Also I have one more question.... I submitted my first version of app... was able to see the introductory offer with trial periods as configured properly, now when i'm trying to submit the next version of app with some loaded features... but with this new version, I'm not able to see the free trial details in payment sheet.

Any possible issues you can think of ?