According to the Apple documentation, best practice dictates that SKPaymentQueue
observer should be added in didFinishLaunchingWithOptions
and removed in applicationWillTerminate
. I note however that applicationWillTerminate
is not guaranteed to be called and that applicationDidEnterBackground
may be call in its stead. Is this safe?
applicationDidEnterBackground
is certainly not an alternative to applicationWillTerminate
. The former indicates that your app has entered the background and will be suspended. When your app is about to return to the foreground applicationWillEnterForeground
will be called.
If applicationWillTerminate
is called then your app is going to terminate. When it is relaunched, didFinishLaunchingWithOptions
will be called.
It is true that applicationWillTerminate
will not always be called, but iOS cannot deliver a payment transaction to a terminated app anyway, so it doesn't matter that the transaction observer may not always be removed.