恢复 iPhone 上已购买的应用内购买项目?
到目前为止,我得到的是:重新安装后,用户需要单击“购买功能”,然后他对 0.99 美元的问题感到害怕,然后必须登录,然后被告知该功能已经购买,并且他可以免费获得。
我知道苹果是一种宗教,用户也是坚定的信徒,但是有没有更好的方法呢? :-) 我想要的是检查该功能而不实际购买它。让用户输入他的帐户信息似乎是必要的,也许购买 0.00 美元的功能?或者有什么方法可以做到这一点?
我在整个应用内购买中使用 MKStoreKit,但任何解决方案都很棒。
更新
感谢darvids0n,你的方法解决了我的问题!这是其他人尝试相同的一些工作代码:
- (void)removePreviousPurchases { //just for sandbox testing
[[MKStoreManager sharedManager] removeAllKeychainData];
}
- (void)restorePreviousPurchases { //needs account info to be entered
if([SKPaymentQueue canMakePayments]) {
[[MKStoreManager sharedManager] restorePreviousTransactionsOnComplete:^(void) {
NSLog(@"Restored.");
/* update views, etc. */
}
onError:^(NSError *error) {
NSLog(@"Restore failed: %@", [error localizedDescription]);
/* update views, etc. */
}];
}
else
{
NSLog(@"Parental control enabled");
/* show parental control warning */
}
}
I got so far: After a reinstall, a user needs to click "buy feature", then he gets scared with the $0.99 question, then has to login and then gets told the feature is already bought and he gets it for free.
I know apple is a religion and users are strong believers, but isn't there a better way? :-) What I want is to check for the feature without actually buying it. Letting the user enter his account info seems to be neccessary, maybe buy a $0.00 feature? or is there a method somewhere that does this?
I'm using MKStoreKit for the whole In-App-Purchase, but any solution would be great.
UPDATE
thanx to darvids0n, your method solved my problem! here's some working code for others trying the same:
- (void)removePreviousPurchases { //just for sandbox testing
[[MKStoreManager sharedManager] removeAllKeychainData];
}
- (void)restorePreviousPurchases { //needs account info to be entered
if([SKPaymentQueue canMakePayments]) {
[[MKStoreManager sharedManager] restorePreviousTransactionsOnComplete:^(void) {
NSLog(@"Restored.");
/* update views, etc. */
}
onError:^(NSError *error) {
NSLog(@"Restore failed: %@", [error localizedDescription]);
/* update views, etc. */
}];
}
else
{
NSLog(@"Parental control enabled");
/* show parental control warning */
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果 0.99 美元的商品是非消耗品,那么您应该提供一个“恢复购买”按钮(或类似的按钮),该按钮会调用
假设您已经添加了交易观察者,并实现了 协议 包括如果要处理恢复的交易(状态为
SKPaymentTransactionStateRestored
),这将起作用。If the $0.99 item is non-consumable, then you should provide a "Restore Purchases" button (or similar) which calls
Assuming you've added a transaction observer already, and implemented the protocol including a case to handle a restored transaction (with state
SKPaymentTransactionStateRestored
) this will work.添加这两个方法:
Add these two methods :