SKPaymentTransactionObserver 的 updatedTransactions 委托方法中什么时候设置交易状态恢复?
When is the transaction state set to restored in the updatedTransactions delegate method of SKPaymentTransactionObserver?
我一直在测试应用程序内购买的代码,但在调用 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)
}
}
}
如果您在 SKPaymentQueue
上调用 restoreCompletedTransactions
并且用户有可恢复的应用内购买,您将获得恢复的交易。有关完整详细信息,请参阅 reference documentation。
我一直在测试应用程序内购买的代码,但在调用 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)
}
}
}
如果您在 SKPaymentQueue
上调用 restoreCompletedTransactions
并且用户有可恢复的应用内购买,您将获得恢复的交易。有关完整详细信息,请参阅 reference documentation。