react-native-iap product list is empty
I am trying to implement react-native iap but i faced some issues. i have already upload my apk to google play console and all need stuff is done. But in code side product list comes empty array. I would be appreciated for your helps.
react-native-iap 4.5.0
react-native 0.63.0
Platform Android
Cannot get product list
Error is The sku was not found. Please fetch products first by calling getItems
Testing Real Device
Code
import React, {useEffect} from 'react'; import {SafeAreaView, Platform, Button} from 'react-native'; import * as RNIap from 'react-native-iap';
const itemSkus = Platform.select({ ios: ['com.example.coins100'], android: ['com.example.coins100'], });
export default function App() { useEffect(() => { const cleanup = RNIap.initConnection() .then((res) => { console.log(res); }) .catch((err) => { console.log(err); });
const products = RNIap.getProducts(itemSkus)
.then((res) => {
console.warn(res);
})
.catch((err) => {
console.warn(err);
});
return () => {
cleanup;
products;
};
}, []);
const buy = () => {
RNIap.requestPurchase('com.example.coins100');
};
return (
Same problem
await RNIap.initConnection()
You shuold resolve the promise!
What is wrong this code. it is still returning empty array of product. Could you please help.
import React, {useEffect} from 'react'; import {SafeAreaView, Platform, Button} from 'react-native'; import * as RNIap from 'react-native-iap'; const itemSkus = Platform.select({ ios: ['com.example.coins100'], android: ['com.example.coins100'], }); export default function App() { useEffect(() => { async function build() { const result = await RNIap.initConnection(); console.log(result); //true const products = await RNIap.getProducts(itemSkus); console.log(products); //[] }
build();
}, []);
const buy = async () => { await RNIap.requestPurchase('com.example.coins100'); };
return (
const result = await RNIap.initConnection();
console.log('result', result);
const products = await RNIap.getSubscriptions(itemSkus)
console.log('Products: ',products)
I tried but it is not working, please help us
Make sure you have your bundle id set correctly. i was using iOS schemes to set different bundle IDs so it wasn't matching the one in itunes connect