所以我似乎无法让updatedTransactions
协议在尝试恢复购买时触发。迅速恢复购买
我在一个视图控制器中有一个按钮,它在我的IAPViewController文件restoreIAP()
中调用以下方法,它是这样设置的。
func restoreIAP(){
SKPaymentQueue.defaultQueue().restoreCompletedTransactions()
}
当用户按下按钮时调用此方法,因此这是处理此类的类。
class SettingsViewController: IAPViewController {
@IBAction func restoreDidTouch(sender: AnyObject) {
restoreIAP()
activityTitle = "Restoring"
}
}
在我IAPViewController
似乎没有什么可以触发这个方法,这样我可以做一些事情。
// Check the transaction
func paymentQueue(queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
// Check the tranactions
for transaction in transactions {
switch transaction.transactionState {
case .Purchasing:
// TODO: Start Activity Indicator
showPurchaseIndicator(activityTitle)
break
case .Purchased:
// TODO: End the purchasing activity indicator
dismissPurchaseIndicator()
print("Transaction completed successfully.")
SKPaymentQueue.defaultQueue().finishTransaction(transaction)
transactionInProgress = false
// TODO: Put method here to unlock all news sources
storiesMethods.unlockAllStories()
break
case .Restored:
// TODO: Start Activity Indicator
// showPurchaseIndicator(activityTitle)
break
case .Failed:
dismissPurchaseIndicator()
notificationMethods.showAlertErrorMessage(self, title: "Purchase", actionMessage: "Dismiss", message: "Unable to complete transaction please try again later.")
SKPaymentQueue.defaultQueue().finishTransaction(transaction)
transactionInProgress = false
break
default:
print(transaction.transactionState.rawValue)
break
}
}
}
看着这个库,我想我会尝试在我的应用中实现这个框架看起来更强大 – Tunds