Therefore, I can not get the protocol to updatedTransactionswork when trying to restore purchases.
I have a button in one view controller that calls the following method in my IAPViewController file restoreIAP(), which is configured like this.
func restoreIAP(){
SKPaymentQueue.defaultQueue().restoreCompletedTransactions()
}
This method is called when the user clicks the button, so this is the class that handles this.
class SettingsViewController: IAPViewController {
@IBAction func restoreDidTouch(sender: AnyObject) {
restoreIAP()
activityTitle = "Restoring"
}
}
In mine, IAPViewControllernothing like this runs this method so that I can do something.
func paymentQueue(queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
for transaction in transactions {
switch transaction.transactionState {
case .Purchasing:
showPurchaseIndicator(activityTitle)
break
case .Purchased:
dismissPurchaseIndicator()
print("Transaction completed successfully.")
SKPaymentQueue.defaultQueue().finishTransaction(transaction)
transactionInProgress = false
storiesMethods.unlockAllStories()
break
case .Restored:
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 source
share