React-native-iap: Empty array of getProducts(itemSkus) in android

Created on 25 Apr 2019  ·  13Comments  ·  Source: dooboolab/react-native-iap

Version of react-native-iap

2.4.9

Version of react-native

0.57.8

Platforms you faced the error (IOS or Android or both?)

android

Expected behavior

To be able to retrieve the products

Actual behavior

I get an empty array

Tested environment (Emulator? Real Device?)

Both emulator and real device

Steps to reproduce the behavior

I've already created an alpha version on play console and debug the app on real device.
I've created subscriptions and not managed products.
Screenshot 2019-04-25 at 13 38 19

Code

const itemSkus = Platform.select({
  android: [
    'com.synesthesiameditation.yearly',
    'com.synesthesiameditation.monthly'
  ]
});
async componentDidMount() {

    try {
      await RNIap.initConnection()
      const products = await RNIap.getProducts(itemSkus);
      console.log(products)
      this.setState({ products });
    } catch (err) {
      console.warn(err); // standardized err.code and err.message available
    }

  }

  componentWillUnmount() {
    RNIap.endConnection();
  }
🙏 help wanted 🤖 android

Most helpful comment

I'm also facing this problem.
[initConnection()] returns 'true' but [getProducts or getSubscriptions] returns empty array..
What/Where should I check for solving this issue?

All 13 comments

I'm also facing this problem.
[initConnection()] returns 'true' but [getProducts or getSubscriptions] returns empty array..
What/Where should I check for solving this issue?

@hyochan same problem here

This will take max 24hours for your products to be available if you've just created the iap products. If this is the case, please close the issue. @thodwris for android, fetching product won't even work in emulator (just fyi).

@hyochan
Thank you for your answer.
I've created the products over 24 hours ago.

@thodwris for android, fetching product won't even work in emulator (just fyi).

What does it mean? And how I will be able to retrieve them and what's the purpose of
RNIap.getProducts(itemSkus)
Maybe I don't get something here.

@thodwris I meant in ios emulator the fetching works but not in android emulator. You shouldn't test anything in android emulator. Also this issue feels unrelated to our module. It would help you better to look for other information related to anrdoid iap and I hope you could comeback when you have some traction.

@hyochan
To be honest I don't understand you well.

What is the purpose of this RNIap.getProducts(itemSkus) eventually, if I don't get the products? :/
Very poor documentation..

@thodwris Hey, your issue haven't been identified yet. I am just trying to help you out here. Poor documentation when nothing has been identified is quite non-sense.

I am begging you to provide some traction after you've identified something in native side. Looking at issue at stackoverflow with different keyword would definitely help. Here is example link.

@hyochan le's say i try IAP in a native android project. Does it still won't work on emulator or is it a react native issue?
I must find an android device

@tmjordan It is same in real android. IAP feature only works in real device.

@hyochan ok thank you very much for your help and support. I will try to find a real device. 👍

@tmjordan

I had to use the getSubscriptions function and not getProducts. I know it's a silly mistake but you could mention that since I attached an image with subscriptions.

Thank you for this library though :)

hey,
I am facing the same issue.Empty array on android.[initConnection()] returns 'true' but [getProducts or getSubscriptions] returns empty array.I have tried everthing.need help.

React-native:0.59.9
react-native-iap: "4.1.1",

I solved it! I am using these versions,

react-native-iap: ^4.3.0
react-native: 0.60.5

just do it like this

const itemSkus = Platform.select({
    ios: [
        '100coins' // just remove bundle id from product id
    ],
    android: [
        '100coins' // just remove bundle id from product id
    ]
});
Was this page helpful?
0 / 5 - 0 ratings