2017-09-13 82 views
0

My Ionic 3应用程序运行良好,除了应用程序内购买。我正在使用原生Cordova通知插件(link here)。我在与其他apis一起工作时并不是最好的,因为我真的需要开始练习。Ionic Cordova In App Purchase - 失败

构建应用程序时不会发生错误,单击按钮时不会发生错误。我简直无能为力。

this.purchaseId = 'my.sku.that.is.active.in.the.ios.and.android.appstore'

代码:

buyButton() { 

this.iap.buy(this.purchaseId) 
    .then((data) => { 
    console.log(data) 
    localStorage.setItem("premium", "1"); 
    this.premiumUser = true; 

    let toast = this.toastCtrl.create({ 
     message: "You are now a premium user. Congradulations and thank you for contributing.", 
     showCloseButton: true, 
     closeButtonText: "Welcome" 
    }); 
    toast.present(); 
    }).catch((err) => { 
    let toast = this.toastCtrl.create({ 
     message: err + "", 
     showCloseButton: true, 
     closeButtonText: "OK" 
    }); 
    toast.present(); 
    }); 

} 

出现没有购买框,没有错误发生。也许有人可能知道修复?你会非常感激。

catch语句在Toast通知中返回'[Object object]'。

+0

你是否正在使用'ionic serve'在浏览器上测试它? – Sampath

+0

也许尝试添加一个错误函数到您的promise.then或之后的一个捕获 –

+0

@Sampath否我不是在Ionic Serve上测试它,而是运行ios 10的iPad。该代码在Android设备上正常运行,并且是SKU的在Playstore和App Store比赛中。嗯... –

回答

0

我讨厌回答我自己的问题,但我找到了答案。您必须先购买Apple的产品ID,然后才能进行购买。我还必须在Apple确认任何购买之前提交银行和税务信息。

+0

离子应用程序购买最终对你来说效果不错吗?你在使用1还是2? –