我目前正在使用沙箱测试我的应用。购买工作,我可以看到正在调用委托函数。当我打电话
SKPaymentQueue.defaultQueue().restoreCompletedTransactions()
我没有得到以下委托方法的任何回复
// Delegate Methods
func paymentQueue(queue: SKPaymentQueue!, updatedTransactions transactions: [AnyObject]!) {
for transaction in transactions as! [SKPaymentTransaction] {
println("Transaction state: \(transaction.transactionState)")
switch transaction.transactionState {
case .Purchased:
completeTransaction(transaction)
break
case .Failed:
failedTransaction(transaction)
break
case .Restored:
println("Restore DELEGATE")
restoreTransaction(transaction)
break
case .Purchasing:
println("Purchasing!")
default:
break
}
}
}
func restoreTransaction(transaction:SKPaymentTransaction) {
println("Restore transaction!!!!!!!!")
if transaction.payment != nil && transaction.payment.productIdentifier != nil {
let productID = transaction.payment.productIdentifier
println(productID)
}
NSNotificationCenter.defaultCenter().postNotificationName("productPurchased", object: nil, userInfo: userInfo)
SKPaymentQueue.defaultQueue().finishTransaction(transaction)
}
func paymentQueue(queue: SKPaymentQueue!, restoreCompletedTransactionsFailedWithError error: NSError!) {
println("Error occured during RESTORE")
}
func paymentQueueRestoreCompletedTransactionsFinished(queue: SKPaymentQueue!) {
println("Restore Finished transactions: \(queue.transactions)")
for transaction in queue.transactions as! [SKPaymentTransaction] {
var productIdentifier = transaction.payment.productIdentifier
println("Restored: \(productIdentifier)")
}
}
是因为Sandbox吗?无论如何,我是否测试恢复是否正常?感谢
编辑:这完全是我的错。代码正在运作。 iPhone我正在测试,有一个名为LocalAPStore的调整,它似乎阻止了恢复。无论如何,至少我了解到即使用户安装了一些hack,我的验证码也能正常工作。