ios - cordova-plugin-purchase:即使在调用命令之后,iOS 也不做任何事情
问题描述
我们正在使用Ionic和cordova-plugin-purchase(也称为 In App Purchase 2)来实现购买订阅。Android 运行良好——iOS 给我们带来了很多问题。
使用产品名称调用order
函数应该会显示 iOS 购买弹出窗口,并且购买应该像往常一样继续。
但是,调用该order
函数后,订阅产品的状态变为requested
但之后没有任何反应。没有弹出窗口出现。奇怪的是,就在昨天,我们能够购买该产品,并且在订阅到期后,我们能够再次购买它。它工作得很好。但是,今天产品再次过期后,点击下单功能只是将产品的状态更新为,requested
但之后没有任何反应。购买在 Android 上也运行得非常好——只是 iOS 非常奇怪并且总是产生错误和问题。有时,当我们更改沙盒帐户并使用新帐户时,它可以工作,但有时,它会突然停止工作。
我们尝试尽可能地简化代码,以至于只有这些是重要的部分:
// this just automatically sets the validator to the correct URL which changes depending on the user's ID.
this.subscriptions.add(
this.status.userData.subscribe(data => {
this.userData = data;
this.store.validator = `https://xxxxxxxxxxx/api/app/users/${ data.id }/purchased`;
})
);
this.store.register([
{
id: this.MONTHLY_SUBSCRIPTION,
type: this.store.PAID_SUBSCRIPTION
},
{
id: this.YEARLY_SUBSCRIPTION,
type: this.store.PAID_SUBSCRIPTION
}
]);
this.store.error((error) => {
console.log('ERROR', error);
});
this.store.when(this.YEARLY_SUBSCRIPTION).updated((p) => {
this.yearly = p;
console.log('yearly', p.state);
});
this.store.when(this.MONTHLY_SUBSCRIPTION).updated((p) => {
this.monthly = p;
console.log('month', p.state);
});
this.store.when(this.YEARLY_SUBSCRIPTION)
.approved(p => p.verify())
.verified(p => p.finish())
.owned(p => this.continue(true, p.id));
this.store.when(this.MONTHLY_SUBSCRIPTION)
.approved(p => p.verify())
.verified(p => p.finish())
.owned(p => this.continue(true, p.id));
this.store.refresh();
调用this.store.order(this.MONTHLY_SUBSCRIPTION);
不会做任何事情。有趣的部分是调用this.store.order(this.YEARLY_SUBSCRIPTION);
确实显示了 iOS 购买弹出窗口。没有错误输出或任何东西。我们之前也尝试过使用this.store.autoFinishTransactions = true;
,this.store.refresh();
但似乎没有任何作用。
我们最近运气不好,如果有人可以提供有关如何解决此问题的建议或提示(可能是插件中的错误?我确实尝试过提交问题,但是...)
非常感谢您,如果需要,我很乐意提供任何进一步的信息。
解决方案
根据插件的文档,store.register()
接受一个对象,而不是一个数组。这可能就是为什么它只注册最后一个产品。
store.register({
id: "cc.fovea.inapp1",
alias: "full version",
type: store.NON_CONSUMABLE
});
https://github.com/j3k0/cordova-plugin-purchase/blob/master/doc/api.md#register
我能想到的另一种可能性是您MONTHLY_SUBSCRIPTION
的价值可能与您在应用商店连接上的应用内购买项目的产品 ID 不匹配。
推荐阅读
- android - Gradle:DSL 元素“useProguard”已过时,将很快被删除
- ios - 使用 CoreBluetooth CBL2CAPChannel 移动数据
- java - 如何单击具有输入类型和值的按钮?
- jquery - 如何使用jQuery ajax 重新加载用户不知道的页面是正在重新加载的页面?
- html - CSS样式表第一次没有链接到HTML web-dev
- android - 使用改造(pdf,ppt,png,jpg)“code = 500,内部服务器错误”上传文件有什么问题
- android - 如何绑定具有多个 IN 值的 SQL 语句?
- android - 如何使用导航视图
- c# - Net Core:用于数据检查的私有成员和数据注释之间的区别
- razorpay - 如何通过razorpay api取消特定用户(最终用户)的订阅