React-native-iap: getProducts always return null

Created on 13 Apr 2018  ·  34Comments  ·  Source: dooboolab/react-native-iap

@dooboolab I am receiving null array after calling getProducts method after prepare method.

📱 iOS 🙏 help wanted 🤖 android

Most helpful comment

@axelkennedal being passive aggressive with the people who voluntarily spend their precious time trying to help you will not get you a long way.

@JJMoon @dooboolab thank you for the great work

All 34 comments

@companytest1206 This should not happen. Could you please share more information? Such as your codes, your products status, os, devices, and etc. For in-app products configuration, please refer to blog.

Here is my code..

async componentDidMount() {
try {
await RNIap.prepare();
const products = await RNIap.getProducts(itemSkus);
console.log('Products', products);
}
catch (err) {
console.warn(err.code, err.message);
}
this.fetchData();

}

My app status is in alpha mode. Using nexus 6 for debugging.

@companytest1206 Your code seems fine. What about your product configuration in playstore or itunesconnect? Please follow the readme and check everything that I've posted here.

I have the same issue.

I have the same issue but I get an empty array (not a null array, whatever that is supposed to mean). I posted about it here.

@systemride @sanilcgs Could you please share the platforms you are having trouble with using getProducts method?

I'm having trouble with this on Android 7.0 (running on an LG G6), developing on MacOS 10.13.4 @dooboolab

Created my app using create-react-native-app package. For integrating in-app purchase I have detached my app. After that I integrated react-native-iap into my app. For me the issue is happened in both iOS and android. I am using Android Studio 3.0.1 and Xcode 9.3. @dooboolab

According to this README of another library it should be possible to get the available products when running in a debug environment (not an Alpha/Beta release), is that correct? (I'm thinking it should be the same for this library as that probably is dependant on how Google handles the IAP).

Another related question; should the SKUs be prefixed with the package name? In other words; is "unlock_premium" or "com.kimer.unlock_premium" correct in my code when the ID I have specified in Google Play Console is "unlock_premium"?

@axelkennedal The SKUS don´t have any format, are totally customizables. In few words: "unlock_premium" or "com.kimer.unlock_premium" are correct.

I understand that you can name a product ID however you want, but what I asked is what should go in my code if I chose the ID "unlock_premium" in Google Play Console (not whether I'm "allowed" to prefix it both in Google Play Console and in my code). You're saying that choosing the ID "unlock_premium" in Google Play Console should work together with both "unlock_premium" and "com.kimer.unlock_premium", correct? I think this needs to be stated somewhere in the README, because it's confusing.

UPDATE

It is now working for me 😄! I tried a couple of things but I'm not sure what was key to getting it to work 🤔 This is anyways what I did:

  1. Reinstalled the package
  2. Changed my import statement from import InAppPurchase from "react-native-iap;" to "import * as InAppPurchase from 'react-native-iap';"
  3. Changed my SKU in the code from "com.kimer.unlock_premium" to "unlock_premium"

@axelkennedal you must use any name, but you must use on Google Play Console> your application > Google Play store> in app products. And the SAME name you must use on source code.

@dooboolab When I am trying to execute RNIap.buyProduct('*') with my productID, I got the error message That item is unavailable. Actually my managed product is in active state. What will be the issue? I can able to list the product details using RNIap.getProducts(itemSkus). Do I need to add the license key into my app??

@sanilcgs could you tell me which platform you are facing error?

@dooboolab I am facing the issue in android platform and developing on MacOS High Sierra (10.13.4)

@sanilcgs are you using our newer module which is ‘0.3.23’? Also similar issue can be found here. https://github.com/dooboolab/react-native-iap/issues/142

@dooboolab Yes I'm using '0.3.23'. My problem is now with RNIap.buyProduct('*'). I got this error **'Error: That item is unavailable.'. Currently I have released my alpha version and published it to google play. I have already created my managed products and all are in active states.

@sanilcgs I posted some help info for that in above issue. I will paste here again. Please check below.

         Do's

1)Create sign apk for your application.
2)Upload your apk on Google play store.
3)Create product for your application.
4)wait for 6-12 hour for update item's on store.
5)Give Billing permissions in Manifest.xml

           Don't

1)Don't use emulator for testing its does not support Billing Services.
2)Don't use unsigned apk for Billing services.

Read more: http://www.androidhub4you.com/2013/03/how-to-inegrate-in-app-purchase-billing.html#ixzz5DqRctVJp

@dooboolab As I already said that my app is not released to production. Now I have released my alpha version only. So can I test this RNIap.buyProduct('**')** with my alpha version or do I need to release my production for testing purchase???

@sanilcgs If you read above thoroughly, you should be aware that you do not need to release apk to production. Just alpha or beta is fine but your apk should be signed as explained. Check above once more and see what you are missing first.

@dooboolab The do's and don'ts above are helpful. For noobs, this would be really helpful to explain in the documentation that you can only test this on an alpha/beta release and if you test this in a dev build on emulator, it will always return an empty array. I see no mention of that anywhere. I'm happy to add this in a pull request if you'd like?

@systemride Any PR is appreciated!

@axelkennedal did all those things, I'm still getting an empty array on iOS. Any ideas?
btw...I'm still testing on a simulator. Is it necessary to test it on actual iOS device?

@axelkennedal getProducts() in iOS works well on simulator. Purchasing actions should be tested on the real device with sandbox apple account.
You might not have finished up App Store product settings perfectly.

@JJMoon if you read my comments you would have known I'm on Android, not iOS.

@axelkennedal being passive aggressive with the people who voluntarily spend their precious time trying to help you will not get you a long way.

@JJMoon @dooboolab thank you for the great work

@raduflp lol what are you talking about? I just pointed out that we are on different platforms

@raduflp Thank you for your kind response and concern. I don't think @axelkennedal meant to be aggressive. He is just too overwhelmed using react-native-iap. Feel like this issue can be closed so I'll close it. Also, any PR is appreciated that may help new generations.

Try it. Work for me:

"You need additionally add your testing account to another special list of accounts "Gmail accounts with testing access", you can find that on play account setting(not project!). On the page where you can see a list of your projects go to settings, and then on "Account details" page (scroll down, it's almost in the bottom of page) you will find the "Gmail accounts with testing access" list."

Set up application licensing
To set up application licensing, start by adding your list of tester's Gmail addresses in the Play Console.

Go to your Play Console.
Select Settings Settings > Account details.
Under "License Testing," add your testers' Gmail addresses.
At the top of the screen, select Save.

I have integrated the react-native-iap and uploaded my signed apk to beta release on play store and also added one subscription plan. I am trying to get the list of subscription by subscription ID in debug mode which is always returning an empty array. Can I actually test the subscription in debug mode?

@ShridharCodewave you use real device or simulator?

@NarekChang I use real device and now somehow I am getting the subscriptions.

Was this page helpful?
0 / 5 - 0 ratings