Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting error message as ERROR Error preparing IAP: "skus" is required #2860

Open
SaveaswebM opened this issue Oct 9, 2024 · 2 comments
Open

Comments

@SaveaswebM
Copy link

this is my code i am using react native expo
import React, { useEffect, useState } from "react";
import { View, Text, Button } from "react-native";
import * as RNIap from "react-native-iap";
const InAppPurchases = () => {
const [products, setProducts] = useState([]);
const [purchasedProducts, setPurchasedProducts] = useState([]);

useEffect(() => {
const initIAP = async () => {
try {
const productIds = ["premium_01"]; // Replace with your actual product IDs
await RNIap.initConnection();
const products = await RNIap.getProducts(productIds);
setProducts(products);
} catch (error) {
console.error("Error preparing IAP:", error);
}
};

@quentininou
Copy link

It seems that the error is related to the fact that, since version 10.0.0 of react-native-iap, it is necessary to pass the product identifiers under the skus key in the getProducts() method. Here is the correction to apply to your code:

const fetchedProducts = await RNIap.getProducts({ skus: productIds });

This should resolve the error. Also, make sure that the product identifiers in productIds match exactly with those configured in Google Play Console or App Store Connect.

@dipen-apptrait
Copy link

dipen-apptrait commented Dec 16, 2024

The code I am using is

useEffect(() => { const initIap = async () => { try { await RNIap.initConnection(); console.log(itemSkus); const productList = await RNIap.getProducts(itemSkus); console.log(productList); setProducts(productList); } catch (err) { console.warn(err); } }; initIap();

The log says

(NOBRIDGE) WARN "skus" is required.

I am already passing the SKUs array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants