如果我没有使用 paymentQueueRestoreCompletedTransactionsFinished 方法但在 paymentQueue中使用已恢复的交易状态(队列:SKPaymentQueue,updatedTransactions Transactions:[SKPaymentTransaction])喜欢这里:
paymentQueue(queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
print("add paymnet")
for transaction:AnyObject in transactions {
let trans = transaction as! SKPaymentTransaction
print(trans.error)
switch trans.transactionState {
case .Purchased. Restored:
...
and
...
@IBAction func RestorePurchases(sender: UIButton) {
SKPaymentQueue.defaultQueue().addTransactionObserver(self)
SKPaymentQueue.defaultQueue().restoreCompletedTransactions()
}
或者我将使用 paymentQueueRestoreCompletedTransactionsFinished 方法,但在 paymentQueue中的.Restored状态(队列:SKPaymentQueue,updatedTransactions Transactions:[SKPaymentTransaction])我将使用这里的刹车操作员:
func paymentQueueRestoreCompletedTransactionsFinished(queue: SKPaymentQueue) {
//restored code here
}
//and
func paymentQueue(queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
print("add paymnet")
for transaction:AnyObject in transactions {
let trans = transaction as! SKPaymentTransaction
print(trans.error)
switch trans.transactionState {
case .Purchased:
...
case .Restored:
break
...
//and
...
@IBAction func RestorePurchases(sender: UIButton) {
SKPaymentQueue.defaultQueue().addTransactionObserver(self)
SKPaymentQueue.defaultQueue().restoreCompletedTransactions()
}
任何帮助将不胜感激!
PS
恢复过程中消耗品和非消耗品购买的代码是否有任何差异?