I've been testing code for in-app purchases, and I can't get the transaction state to set to restored in the updatedTransactions SKPaymentTransactionObserver delegate method when it's called. When does that method call with that transaction state?
func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
for transaction in transactions {
switch transaction.transactionState {
// Call the appropriate custom method for the transaction state.
case SKPaymentTransactionState.purchasing:
showTransactionAsInProgress(transaction, deferred: false)
case SKPaymentTransactionState.deferred:
showTransactionAsInProgress(transaction, deferred: true)
case SKPaymentTransactionState.failed:
failedTransaction(transaction)
case SKPaymentTransactionState.purchased:
completeTransaction(transaction)
case SKPaymentTransactionState.restored:
restoreTransaction(transaction)
}
}
}
You get a restored transaction if you call restoreCompletedTransactions
on SKPaymentQueue
and the user has restorable in-app purchases. See the reference documentation for complete details.