The IAP is working, but when I move between views and come back to the IAP VC, the app crashes in SKPaymentQueue.defaultQueue().addPayment(payment)
ERROR: EXC_BAD_ACCESS
I found the solution, you need to clean the SKPaymentQueue
in the viewWillDisappear
Update Swift 4.x
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
SKPaymentQueue.default().remove(self)
}
Swift 2.3
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated: animated)
SKPaymentQueue.defaultQueue().removeTransactionObserver(self)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With