iOS IAP restore doesn't work

允我心安 提交于 2021-02-08 16:58:56

问题


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()

Next

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.

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:

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...


回答1:


I request the receipt before restoring purchases:

let receiptRefreshRequest: SKRequest = SKReceiptRefreshRequest()
receiptRefreshRequest.delegate = self
receiptRefreshRequest.start()

Then after response I do the restoration

public func requestDidFinish(request: SKRequest) {
    if request == receiptRefreshRequest {
        SKPaymentQueue.defaultQueue().restoreCompletedTransactions()
    }
}


来源:https://stackoverflow.com/questions/37615629/ios-iap-restore-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!