'react-native-iap getProducts return empty array

I'am using react-native-iap for in-app purchase. But the getProducts method return empty array. Below is what I did for it.

  1. insert billing permission in AndroidManifest.xml like
<uses-permission android:name="com.android.vending.BILLING" />
  1. upload this android app AAB to alpha version and didn't release it.
  2. create product with id productid1 and productid2. productid1 is active apk and productid2 is inactive.
  3. make following code
import * as RNIap from 'react-native-iap';

const itemSkus = Platform.select({
  ios: ['productid1', 'productid2'],
  android: ['productid1', 'productid2'],
});

...
componentDidMount() {
  RNIap.initConnection().then(conn => {
    // conn is true
    RNIap.getProducts(itemSkus)
      .then(res => {
        // res is []
      })
      .catch(err => {
        // no err
      });
  });
}
...

As like comment of getProducts always returns null by hyochan on 4 May 2018, should I wait for the products to update? or is there any problem on my code? or anything?

My environment is

  • react-native: "0.60.5"
  • react-native-iap: "^4.3.3"


Solution 1:[1]

For those facing this issue with iOS, make sure you finalise the agreements and tax, then make sure to copy and paste this pod 'RNIap', :path => '../node_modules/react-native-iap' into the pod file, then cd ios && pod install && cd ..(run terminal commands from the application directory). I had this issue and it turns out I'd skipped these very important steps.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Muganwas