我想向我的應用添加還原選項。 我添加了一個按鈕,這是否2行:Restore Purchase - Swift
SKPaymentQueue.defaultQueue().restoreCompletedTransactions()
SKPaymentQueue.defaultQueue().addTransactionObserver(self)
而且我有功能,多數民衆贊成應該檢查是否恢復成功:
func paymentQueue(queue: SKPaymentQueue!, updatedTransactions transactions: [AnyObject]!) {
for transaction:AnyObject in transactions {
if let trans:SKPaymentTransaction = transaction as? SKPaymentTransaction{
switch trans.transactionState {
case .Purchased, .Restored:
SKPaymentQueue.defaultQueue().finishTransaction(transaction as SKPaymentTransaction)
//code
break;
case .Failed:
SKPaymentQueue.defaultQueue().finishTransaction(transaction as SKPaymentTransaction)
//code
break;
default:
break;
}
}
}
但是,當我按下按鈕沒有反應,不會激活paymentQueue功能。
代碼有問題嗎? 什麼問題?
謝謝。
你檢查嗎?可能該文件可以幫助你。 http://stackoverflow.com/questions/28734890/restore-inapp-purchase-using-swift-ios – aliyasar 2015-04-03 19:53:31
這是相同的代碼,我的是不是? – Omer 2015-04-03 19:56:34