react-native-iap icon indicating copy to clipboard operation
react-native-iap copied to clipboard

react-native-iap product list is empty

Open xhsynx opened this issue 6 years ago • 5 comments

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

JordaoMemoria avatar Jul 13 '20 22:07 JordaoMemoria

 await RNIap.initConnection()

You shuold resolve the promise!

hyochan avatar Jul 14 '20 01:07 hyochan

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

JordaoMemoria avatar Jul 15 '20 01:07 JordaoMemoria

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

dennis3124 avatar Jul 16 '20 23:07 dennis3124