iOS IAP还原不起作用 [英] iOS IAP restore doesn't work
问题描述
我有带有IAP的ios应用.我以测试人员的身份在沙箱中购买产品,一切正常.我收到收据并把它切丁.然后,我重新安装该应用程序,我正在尝试还原IAP并致电
I have the ios App with IAP. I buy product in sandbox as tester user and everything is Ok. I receive receipt and parce it. Then I re-install the App, I'm trying to restore IAP and call
SKPaymentQueue.defaultQueue().restoreCompletedTransactions()
下一步
paymentQueueRestoreCompletedTransactionsFinished(queue: SKPaymentQueue)
被调用.什么也没有恢复.我想一定是有
is called. Nothing restored. I suppose there must be call of
paymentQueue(queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction])
但是它不见了!收据也不存在.
but it is missing! The receipt also doesn't exist.
必须要恢复交易(因为如果我再次购买产品,StoreKit说它已经购买了),我在做什么错了?
There must be transactions to restore (because if I buy product again StoreKit says that it is already purchased) What am I doing wrong?
UPD:
我要还原的产品是不可更新的订阅.如果这是唯一可还原的产品,则Apple不会返回交易清单.如果购买了其他产品(例如,非消耗品),Apple将返回完整的交易清单...
The product I want to restore is Non-renewable subscription. If this is the only kind of products to restore, Apple does not return transactions list. If there was another product purchased (for example, Non-Consumable) Apple returns full list of transactions...
推荐答案
在恢复购买之前,我要求收据:
I request the receipt before restoring purchases:
let receiptRefreshRequest: SKRequest = SKReceiptRefreshRequest()
receiptRefreshRequest.delegate = self
receiptRefreshRequest.start()
然后响应后我进行恢复
public func requestDidFinish(request: SKRequest) {
if request == receiptRefreshRequest {
SKPaymentQueue.defaultQueue().restoreCompletedTransactions()
}
}
这篇关于iOS IAP还原不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!