UpdatedTransactions(transactionState == .restored)与paymentQueueRestoreCompletedTransactionsFinished [英] updatedTransactions(transactionState == .restored) vs paymentQueueRestoreCompletedTransactionsFinished

查看:57
本文介绍了UpdatedTransactions(transactionState == .restored)与paymentQueueRestoreCompletedTransactionsFinished的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所述,实际有什么不同?

As the title describes, what is the actual different?

如果我有这个:

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

我是否仍需要使用此代码(如果是,请在此处使用什么代码,以及 transactionState == .restored 中的什么代码?:

Do I still need to use this (if yes, what code to use here, and what code in transactionState == .restored?:

func paymentQueueRestoreCompletedTransactionsFinished(_ queue: SKPaymentQueue) {

}

推荐答案

开始还原交易时,所有可用交易都会以 .restored 状态显示给您的支付队列观察者.此时,您应该恢复交易;有效的处理方式与处理初次购买的方式相同.

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.

根据可还原的事务,您将看到从0到n的事务(可能没有任何事务可还原).

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

显示所有可用交易后,您将致电 paymentQueueRestoreCompletedTransactionsFinished .每次调用 restoreCompletedTransactions 时,始终会对此方法进行1次调用.

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.

请注意,没有还原的事务的详细信息传递给此方法.此方法的目的是允许您执行任何最后的整理工作,例如更新UI.

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.

例如,当用户点击还原"按钮时,您可能会显示正在还原"消息,而当您致电 paymentQueueRestoreCompletedTransactionsFinished

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

这篇关于UpdatedTransactions(transactionState == .restored)与paymentQueueRestoreCompletedTransactionsFinished的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆