恢复已经在iPhone上购买了应用内购买? [英] Restore already bought in-app-purchases on iPhone?

查看:404
本文介绍了恢复已经在iPhone上购买了应用内购买?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我到目前为止:重新安装后,用户需要点击购买功能,然后他会因为0.99美元的问题而感到害怕,然后必须登录才会被告知该功能已经购买并且他免费获得。

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.

我知道苹果是一种宗教,用户是坚定的信徒,但是不是更好的方法吗? :-)我想要的是检查功能而不实际购买它。让用户输入他的帐户信息似乎是必要的,也许买一个0.00美元的功能?或者是否有某种方法可以做到这一点?

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?

我正在使用MKStoreKit进行整个应用内购买,但任何解决方案都会很棒。

I'm using MKStoreKit for the whole In-App-Purchase, but any solution would be great.

更新

thanx到darvids0n,你的方法解决了我的问题!这是其他人尝试相同的工作代码:

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 */
    }
}


推荐答案

如果0.99美元的商品是非消费品,那么你应该提供一个恢复购买按钮(或类似的)按钮

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

[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];

假设您已经添加了一个事务观察器,并实现了协议,包括处理已恢复交易的案例(州 SKPaymentTransactionStateRestored )这将有效。

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.

这篇关于恢复已经在iPhone上购买了应用内购买?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆