【问题标题】:InAppPurchase erreurInAppPurchase 错误
【发布时间】:2021-06-12 11:59:34
【问题描述】:

离子:

@ionic/cli: "^6.10.0",
Ionic Framework               : "@ionic/angular": "^5.1.1"
@angular-devkit/build-angular : 0.1102.13
@angular-devkit/schematics: "^9.1.7",
@angular/cli: "^9.1.7",
@ionic/angular-toolkit: "~2.0.0",

系统:

NodeJS:v12.14.0 npm:6.13.4 操作系统:macOS Big Sur 版本 11.2.3 Xcode:Xcode 12.4 构建版本 12D4e 在需要在 Ionic/iOS 应用程序中激活应用内购买时,我在 App Store Connect 中构建了我的产品以进行测试。在需要在 Ionic/iOS 应用程序中激活应用内购买时,我将我的产品构建在App Store Connect 进行测试。 enter image description here 我开发了一个带有在线支付功能的 Angular / Ionic 应用程序,并创建了一个 ios 应用程序,当我发送它进行验证时,它被 Apple 拒绝,要求集成“应用内购买”,这就是我使用插件“In- App-Purchase2" 来管理购买但是当我尝试访问我创建的包时,XCode 会启动以下记录器:"Undefined" or nothing display 。 我不明白为什么我找不到我的产品(我的产品列表是空的),我注意到我的应用程序和 AppleStoreConnect 之间没有连接.. 你能帮我看看我使用的方法是否很好,以及为什么它不能很好地工作。 我的代码: Pasted Graphic 4

Pasted Graphic 3

记录 Xcode Loadina network plugin

已签署申请协议 Capture d’écran, le 2021-06-11 à 12 24 03

Ps:我在模拟器中测试过

【问题讨论】:

  • do not post images of code - 在此处发布文字。
  • 我不知道 Ionic 但我知道 IAP 必须在真机上测试,它在模拟器中不起作用

标签: ios angular xcode ionic-framework in-app-purchase


【解决方案1】:

嗨@Juliana,欢迎来到社区!让我们帮助您使用 sn-p 代码。在请求处理产品之前,您需要确保 Store 已准备就绪,并使用 NgZone 获取产品数据。

  constructor(private store: InAppPurchase2){
    this.productId = 'my_product_name'
  }

  ngOnInit() {
    this.platform.ready().then(() => {
      if (this.platform.is('ios')) {
        this.setupPurchase();
      }
    });
  }

  setupPurchase() {    
    this.store.verbosity = this.store.DEBUG;
    this.store.register({
      id: this.productId,
      type: this.store.NON_CONSUMABLE
    });
    console.log('verbosity ?? ', JSON.stringify(this.store.verbosity));
    this.store.ready(() => {   
      this.registerHandlersForPurchase(this.productId);
    });
    // refresh/store purchase
    this.store.refresh();
  }

  registerHandlersForPurchase(productId) {
    // Approved
    this.store.when(productId).approved((product: IAPProduct) => {
      console.log('Approved ?? ', JSON.stringify(product));
      // Product Finish
      product.finish();
    });

    // User closed the native purchase dialog
    this.store.when(this.productId).cancelled((product) => {
      console.error('User Canceled! ', product);
    });

    this.store.refresh();
    
    this.product = this.store.get(this.productId);
    if (!!this.product.id && !!this.product.priceMicros) {
      this.zone.run(() => {
        // Use on HTML view to show the products
        this.displayProduct = this.product;
      });
    }
    console.log('Handlers produto ?? ', JSON.stringify(this.product));
    // Track all store errors
    this.store.error( (err) => {
      console.error('Store Error ' + JSON.stringify(err));
    });
  }

请调整它以适应您的代码并在本机设备上运行。您将在调试时看到 console.log() 以及产品的错误和状态。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-07-19
    • 1970-01-01
    • 2020-05-14
    • 2011-08-30
    • 2017-03-26
    • 1970-01-01
    • 1970-01-01
    • 2014-12-30
    相关资源
    最近更新 更多