littleNoob littleNoob - 6 months ago 50
Swift Question

iOS IAP restore doesn't work

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

Answer

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