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]'。
你是否正在使用'ionic serve'在浏览器上测试它? – Sampath
也许尝试添加一个错误函数到您的promise.then或之后的一个捕获 –
@Sampath否我不是在Ionic Serve上测试它,而是运行ios 10的iPad。该代码在Android设备上正常运行,并且是SKU的在Playstore和App Store比赛中。嗯... –