gpt4 book ai didi

javascript - 如何修复 'yourAPI is not defined'

转载 作者:行者123 更新时间:2023-11-28 03:40:42 25 4
gpt4 key购买 nike

我现在正在研究react-native-iap。在工作中,我遇到了这个问题。“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”是什么?请帮忙,任何人都可以了解“yourAPI”吗?

最佳答案

这实际上是您的 api :) 这意味着当通过 native 应用内购买购买产品时,您想要调用您的 api(后端)。举四个例子,在游戏中,您可以通过应用内购买向游戏玩家出售入门包,首先用户将为此入门包向 google play 或应用商店支付一定的费用。您应该知道此操作是否成功完成,并且您应该将此入门工具包提供给用户。为此,您应该在此监听器内部进行调用,例如 backendApi.sold(purchase.transactionReceipt).then((result) => {});

关于javascript - 如何修复 'yourAPI is not defined',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57327523/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com