问题
As the title describes, what is the actual different?
If I have this:
func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
for transaction in transactions {
if transaction.transactionState == .purchased {
} else if transaction.transactionState == .failed {
} else if transaction.transactionState == .restored { // <- This one
}
}
Do I still need to use this (if yes, what code to use here, and what code in transactionState == .restored
?:
func paymentQueueRestoreCompletedTransactionsFinished(_ queue: SKPaymentQueue) {
}
回答1:
When you start restoring transactions, any available transactions are presented to your payment queue observer with the .restored
state. At this point you should restore the transaction; effectively processing it in the same way that you processed the initial purchase.
Depending on what transactions are available to be restored, you will get from 0 to n transactions presented (There may not be any transactions available for restoration).
Once all available transactions have been presented, you will get a call to paymentQueueRestoreCompletedTransactionsFinished
. You will always get 1 call to this method for each time you call restoreCompletedTransactions
.
Note that no details of the restored transactions are passed to this method. The purpose of this method is to allow you to perform any final housekeeping such as updating your UI.
For example, you could display a "Restoring" message when the user taps your restore button and hide that message when you get the call to paymentQueueRestoreCompletedTransactionsFinished
来源:https://stackoverflow.com/questions/60959941/updatedtransactionstransactionstate-restored-vs-paymentqueuerestorecomplet