SKPaymentTransactionObserver的updatedTransactions委托方法何时将事务状态设置为还原?

时间:2018-09-29 05:12:39

标签: ios swift skpaymenttransaction

我一直在测试应用程序内购买的代码,并且在调用updatedTransactions SKPaymentTransactionObserver委托方法时,无法将交易状态设置为还原。该方法何时以该交易状态调用?

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

}

1 个答案:

答案 0 :(得分:1)

如果您在restoreCompletedTransactions上致电SKPaymentQueue,并且用户拥有可恢复的应用内购买,则交易将恢复。有关完整的详细信息,请参见reference documentation