Это мой код.
Код: Выделить всё
const items = Platform.select({
ios: ["item_25", "item_55", "item_155"],
android: [""],
})
Код: Выделить всё
const {
connected,
subscriptions, //returns subscriptions for this app.
getSubscriptions, //Gets available subsctiptions for this app.
getProducts,
products,
currentPurchase, //current purchase for the tranasction
finishTransaction,
purchaseHistory, //return the purchase history of the user on the device (sandbox user in dev)
getPurchaseHistory, //gets users purchase history
requestPurchase
} = useIAP();
const handleGetProducts = async () => {
setGetPlaning(true);
try {
await getProducts({ skus: items });
} catch (error) {
errorLog({ message: "handleGetProducts", error });
}
};
useEffect(() => {
handleGetProducts();
}, [connected]);
const handlePurchase = async (productId) => {
setLoading(true);
try {
await requestPurchase({
sku: productId,
});
setLoading(false);
} catch (error) {
setLoading(false);
if (error instanceof PurchaseError) {
console.error({ message: `[${error.code}]: ${error.message}`, error });
} else {
console.error({ message: "handlePurchase", error });
}
}
};
Код: Выделить всё
handlePurchase('item_25')}>
Purchase
Но после нажатия кнопки покупки это модальное окно закрывается и открывается снова.
Я не знаю причину этого.
Кто-нибудь поможет мне с этой проблемой?
Спасибо.
Подробнее здесь: https://stackoverflow.com/questions/779 ... g-properly