我现在在研究反应本土化。在工作的时候,我遇到了这个问题。“yourAPI未定义”
import RNIap, {
purchaseErrorListener,
purchaseUpdatedListener,
type ProductPurchase,
type PurchaseError
} from 'react-native-iap';
class RootComponent extends Component<*> {
purchaseUpdateSubscription = null
purchaseErrorSubscription = null
componentDidMount() {
this.purchaseUpdateSubscription = purchaseUpdatedListener((purchase: ProductPurchase) => {
console.log('purchaseUpdatedListener', purchase);
const receipt = purchase.transactionReceipt;
if (receipt) {
yourAPI.deliverOrDownloadFancyInAppPurchase(purchase.transactionReceipt)
.then((deliveryResult) => {
if (isSuccess(deliveryResult)) {
if (Platform.OS === 'ios') {
RNIap.finishTransactionIOS(purchase.transactionId);
} else if (Platform.OS === 'android') {
// If consumable (can be purchased again)
RNIap.consumePurchaseAndroid(purchase.purchaseToken);
// If not consumable
RNIap.acknowledgePurchaseAndroid(purchase.purchaseToken);
}
} else {
// Retry / conclude the purchase is fraudulent, etc...
}
});
}
});
this.purchaseErrorSubscription = purchaseErrorListener((error: PurchaseError) => {
console.warn('purchaseErrorListener', error);
});
}
componentWillUnmount() {
if (this.purchaseUpdateSubscription) {
this.purchaseUpdateSubscription.remove();
this.purchaseUpdateSubscription = null;
}
if (this.purchaseErrorSubscription) {
this.purchaseErrorSubscription.remove();
this.purchaseErrorSubscription = null;
}
}
}在这里我不确定什么是'yourAPI.deliverOrDownloadFancyInAppPurchase'?请帮助,任何人谁能知道‘你的can’?
发布于 2019-08-02 19:14:26
这实际上是您的api :)这意味着当一个产品是用本地的应用程序内购买,您想要调用您的api (后端)。在一个游戏中的四个例子,你可以出售一个初学者包与应用程序内购买,首先用户将支付一个价值谷歌发挥或应用商店为这个初学者包。你应该知道这个动作是否成功地完成了,你应该把这个初学者工具包给用户。为此,您应该在这个监听器中进行调用,比如backendApi.sold(purchase.transactionReceipt).then((result) => {});。
https://stackoverflow.com/questions/57327523
复制相似问题