【发布时间】:2017-06-21 10:34:56
【问题描述】:
我真的很享受 Ionic 2 应用程序的开发,但目前我在购买过程中遇到了一些问题。
如何在应用启动时检查用户是否进行了有效购买? 我想实现以下行为:
用户已订阅: -> 显示 PAGE A
用户没有订阅: -> 显示 PAGE B
订阅信息需要保存在本地吗?
** 编辑 **
我正在使用 firebase 后端,可以将购买的内容存储在那里。
这是我的功能:
buyCoach(productName: string): void {
console.log(productName);
InAppPurchase
.getProducts([productName])
.then((products) => {
InAppPurchase
.buy(productName)
.then((data)=> {
// {
// transactionId: ...
// receipt: ...
// signature: ...
// }
// maybe store somethign to firebase? But what?
})
.catch((err)=> {
console.log("error buy");
console.log(JSON.stringify(err));
});
})
.catch((err) => {
console.log("error getProducts");
console.log(JSON.stringify(err));
});
}
【问题讨论】:
标签: cordova firebase ionic-framework firebase-realtime-database ionic2