首页 > 解决方案 > 无法回电购买的产品?适用于 React 本机 iOS 的 IAP

问题描述

''''
requestPurchase = async (sku) => {
        try {
          await RNIap.requestPurchase(sku)
                .then(async (result) => {
                    console.log('IAP req sub', result);
                    if (Platform.OS === 'android') {
                        console.log("android")
                        // can do your API call here to save the purchase details of particular user
                    } else if (Platform.OS === 'ios') {
                        console.log("recipt",result.transactionReceipt)
                        setProductId(result.productId);
                        setReceipt(result.transactionReceipt);
                        // can do your API call here to save the purchase details of particular user
                    }
                   // setBuyIsLoading(false);
                })
                .catch((err) => {
                    //setBuyIsLoading(false);
                    console.warn(`IAP req ERROR %%%%% ${err.code}`, err.message, isModalVisible);
                    setError(err.message);
                });
            console.log("Hiiii......", sku)
        } catch (err) {
            console.log("Error.....", err.message)
            console.warn(err.code, err.message);
        }
    };    
'''

我们要求## 标题 ## 购买产品并能够购买产品但未收到任何产品购买回电。

标签: react-nativein-app-purchasereact-native-iosreact-native-iap

解决方案


尝试在 then 子句中删除 async before (result)。


推荐阅读