恢复 iPhone 上已购买的应用内购买项目?

发布于 2024-12-09 15:13:45 字数 1038 浏览 1 评论 0原文

到目前为止,我得到的是:重新安装后,用户需要单击“购买功能”,然后他对 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

○闲身 2024-12-16 15:13:45

如果 0.99 美元的商品是非消耗品,那么您应该提供一个“恢复购买”按钮(或类似的按钮),该按钮会调用

[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];

假设您已经添加了交易观察者,并实现了 协议 包括如果要处理恢复的交易(状态为 SKPaymentTransactionStateRestored),这将起作用。

If the $0.99 item is non-consumable, then you should provide a "Restore Purchases" button (or similar) which calls

[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];

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.

只怪假的太真实 2024-12-16 15:13:45

添加这两个方法:

[[SKPaymentQueue defaultQueue] addTransactionObserver:self];

[[SKPaymentQueue defaultQueue]restoreCompletedTransactions];

Add these two methods :

[[SKPaymentQueue defaultQueue] addTransactionObserver:self];

[[SKPaymentQueue defaultQueue]restoreCompletedTransactions];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文