I have the app on the AppStore where restore purchases work fine (the build is done with Swift 2.2). However, I just switched to Swift 3 and xCode 8 and restoreCompletedTransactions stopped working. The paymentQueue is not called and paymentQueueRestoreCompletedTransactionsFinished returns 0 transactions in the queue for the real appleId user on the iTuneStore. However, when I switched to the sandbox test account it worked (even in Swift 3). Here is the code... Does anyone know if there are some changes regarding this in xCode 8?
func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction])
{
for transaction in transactions {
switch transaction.transactionState {
case SKPaymentTransactionState.purchased:
NSLog("Transaction completed successfully.")
SKPaymentQueue.default().finishTransaction(transaction)
transactionInProgress = false
if (self.selectedProductIndex != -1)
{
delegate.didBuyTraining()
}
break
case SKPaymentTransactionState.failed:
NSLog("Transaction Failed");
SKPaymentQueue.default().finishTransaction(transaction)
transactionInProgress = false
break
case SKPaymentTransactionState.restored:
NSLog("Transaction completed successfully.")
SKPaymentQueue.default().finishTransaction(transaction)
transactionInProgress = false
break
default:
NSLog(String(transaction.transactionState.rawValue))
break
}
}
}
func paymentQueueRestoreCompletedTransactionsFinished(_ queue: SKPaymentQueue!) {
var productIds = [String]()
let count = queue.transactions.count
for var transaction in queue.transactions{
let prodID = transaction.payment.productIdentifier
productIds.append(prodID)
}
for var prodID in productIds {
for var prod in productsArray {
if prod?.productIdentifier == prodID{
set_defaults((prod?.localizedTitle)!)
}
}
}
}