SKPaymentTransactionObserver Error – Does Not Conform To Protocol

If you are trying to add IAP (In-App Purchasing) to your iOS app, you may have stumbled across this little hurdle.

I implemented the SKPaymentTransactionObserver protocol as suggested by so many people online but I kept receiving an error informing me that my class didn’t conform to the protocol. The only required function is the updatedTransactions function so I couldn’t understand what was wrong as XCode was completing the entry for me. However, there seems to be an error in the auto-complete (this may be out of date if reading long after 19th January 2016).

Instead of the function below created by autocomplete:

func paymentQueue(queue: SKPaymentQueue!, updatedTransactions transactions: [AnyObject]!)

This is the correct syntax for the function:

func paymentQueue(queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction])

This wasted a day of my life! I just hope this saves some people from the same issue.

Best of luck!