React-native-iap: getProducts always returns an empty array on iOS

Created on 3 Apr 2018  路  10Comments  路  Source: dooboolab/react-native-iap

Version of react-native-iap

0.3.0-beta5

Expected behavior

Should return an array of purchasable products just like in Android.

Actual behavior

Returns an empty array.

Steps to reproduce the behavior

var purchase_ids = {
  ios: [
    'pro'
  ],
  android: [
    'pro'
  ]
};

return RNIap.prepare()
  .then(() => RNIap.getProducts(Platform.select(purchase_ids)))
  .then(items => {
    if (__DEV__) console.log('RNIap Products:', items);
  });

Yes I do have the in app purchases set up in iTunes Connect:

screen shot 2018-04-03 at 10 08 46 am

And again, this works perfect on Android.

Most helpful comment

@dooboolab Between changing the status to "Waiting for Review" and also making sure that I had contracts under "Paid Applications" submitted, I've got it working. Thank you so much for your assistance and your react native module!

All 10 comments

@kodie Hi! Thank you for the issue. Well, we've been testing this case lots of time and this should work fine. Maybe app store is pending for your In-App Purchase so you might wait some time or could you check other things like your pacakage name and that you are in correct dev account?

Check the names. I see PRO and pro.
There are several names in iOS products.

@dooboolab @JJMoon I have tried both names. Officially are we supposed to use the Reference Name or the Product ID? I have had the product added in iTunes Connect for quite some time. Package name is fine. The IAP has had a "Waiting for Review" status for weeks. I have tried submitting the app to the app store and they denied it due to not being able to purchase the in app product because I can't get this module to work for iOS.

Also, on the device itself I'm not logged into any account. If I go ahead and do getAvailablePurchases() after getProducts() (even though it's empty) I get a dialog that asks me to log in. If I log into my sandbox account I get the following error:

Time:2018-04-04T14:09:14.0801320Z
09:09:31.213 Init.js:44 RNIap Error: Error: An unknown or unexpected error has occured. Please try again later.
    at createErrorFromErrorData (NativeModules.js:123)
    at NativeModules.js:80
    at MessageQueue.__invokeCallback (MessageQueue.js:400)
    at MessageQueue.js:139
    at MessageQueue.__guardSafe (MessageQueue.js:316)
    at MessageQueue.invokeCallbackAndReturnFlushedQueue (MessageQueue.js:138)
    at debuggerWorker.js:72

It doesn't ask me to log in until I run getAvailablePurchases() though which I thought was kind of odd. I have also changed my in app purchases name to use the a product identifier like com.itsahappymedium.myapp.ios.pro but still getting an empty array.

@kodie you are suppose to use the product id. Also, it is hard for me to figure out your problem because I am not in your environment. What I am doubting about your problem is the configuration on app store for your iap products. Could you share the screenshot for your in app products you setup on itunesconnect? Also, I am writing some blog on medium about in-app-purchase in both platforms. I will alert you once more if it is ready.


Ah. I've just found out what your problem might be. Your products should be in ready for submit status rather than Waiting for Review. Please edit your product so that you have the correct status. What you are writing up here is not actually our issue. Reading about IAP for apple would help you better too.

@dooboolab Between changing the status to "Waiting for Review" and also making sure that I had contracts under "Paid Applications" submitted, I've got it working. Thank you so much for your assistance and your react native module!

@dooboolab @kodie Can you guys clarify what status should be? I am just trying to test a consumable product (before submitting to app store). My app as a whole is under "Prepare for Submission" for the first time and I have 1 test consumable product. Under that product I checked "Availability: Cleared for Sale". Still see empty products. I just submitted my Paid Applications contract though so we will see if that resolves the issue.

@dooboolab @kodie I was able to get it working.

There is wrong information floating all over these issues such as:

  • requires a particular status
    => it does not. my status is fresh with "1.0 Prepare for Submission"
  • need it import as import * as RNIap from 'react-native-iap';
    => it doesn't matter. import RNIap from 'react-native-iap'; works too
  • products should be listed as product, not com.company.product
    => false. com.company.product works too

I believe what got it working for me was submitting my Paid Applications contract. This also enabled "Auto-renewable Subscriptions" for me.

Downgrading from 2.4.x to 2.3.x fixed it for us.

Hello users,
I also face this issue after the some week found a solution.

// Purchase items
const itemSkus = Platform.select({
ios: [
"1299_Package"
],
android: [
"1299_Package"
]
});

Enter only product id not with the build identifier.

Was this page helpful?
0 / 5 - 0 ratings