首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何修复“yourAPI未定义”

如何修复“yourAPI未定义”
EN

Stack Overflow用户
提问于 2019-08-02 13:30:45
回答 1查看 408关注 0票数 1

我现在在研究反应本土化。在工作的时候,我遇到了这个问题。“yourAPI未定义”

代码语言:javascript
复制
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’?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-08-02 19:14:26

这实际上是您的api :)这意味着当一个产品是用本地的应用程序内购买,您想要调用您的api (后端)。在一个游戏中的四个例子,你可以出售一个初学者包与应用程序内购买,首先用户将支付一个价值谷歌发挥或应用商店为这个初学者包。你应该知道这个动作是否成功地完成了,你应该把这个初学者工具包给用户。为此,您应该在这个监听器中进行调用,比如backendApi.sold(purchase.transactionReceipt).then((result) => {});

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57327523

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档