我在 AppStore 上有应用程序,恢复购买工作正常(构建是使用 Swift 2.2 完成的)。但是,我刚刚切换到 Swift 3 和 xCode 8,restoreCompletedTransactions 停止工作。未调用 paymentQueue 并且 paymentQueueRestoreCompletedTransactionsFinished 在 iTuneStore 上为真正的 appleId 用户返回队列中的 0 个事务。但是,当我切换到沙盒测试帐户时,它可以工作(即使在 Swift 3 中)。这是代码...有谁知道xCode 8中是否对此有一些更改?
func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction])
{
for transaction in transactions {
switch transaction.transactionState {
case SKPaymentTransactionState.purchased:
NSLog("Transaction completed successfully.")
SKPaymentQueue.default().finishTransaction(transaction)
transactionInProgress = false
if (self.selectedProductIndex != -1)
{
delegate.didBuyTraining()
}
break
case SKPaymentTransactionState.failed:
NSLog("Transaction Failed");
SKPaymentQueue.default().finishTransaction(transaction)
transactionInProgress = false
break
case SKPaymentTransactionState.restored:
NSLog("Transaction completed successfully.")
SKPaymentQueue.default().finishTransaction(transaction)
transactionInProgress = false
break
default:
NSLog(String(transaction.transactionState.rawValue))
break
}
}
}
func paymentQueueRestoreCompletedTransactionsFinished(_ queue: SKPaymentQueue!) {
var productIds = [String]()
let count = queue.transactions.count
for var transaction in queue.transactions{
let prodID = transaction.payment.productIdentifier
productIds.append(prodID)
}
for var prodID in productIds {
for var prod in productsArray {
if prod?.productIdentifier == prodID{
set_defaults((prod?.localizedTitle)!)
}
}
}
}