updatedTransactions(transactionState == .restored) vs paymentQueueRestoreCompletedTransactionsFinished

怎甘沉沦 提交于 2021-01-29 03:19:19

问题


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

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