'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.
- insert billing permission in
AndroidManifest.xmllike
<uses-permission android:name="com.android.vending.BILLING" />
- upload this android app AAB to alpha version and didn't release it.
- create product with id
productid1andproductid2.productid1is active apk andproductid2is inactive. - 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 |
