Where to setup up SKPaymentTransactionObserver?

The apple document about “Setting Up the Transaction Observer for the Payment Queue” says

It is important to add the observer at launch, in application:didFinishLaunchingWithOptions:, to ensure that it persists during all launches of your app, receives all payment queue notifications, and continues transactions that may be processed outside the app, such as:

Promoted in-app purchases

Background subscription renewals

Interrupted purchases

In my case, If I received a ‘purchased’ or ‘restored’ event I need to ‘unlock’ the content. This involves doing something in my CoreData Stack. I am setting up the coreData stack (making the NSPersistentContainer, loadPersistentStores  etc.) and setting up a few related objects  in my initial View Controller (in viewdidload)

So I am doing pretty early, as soon as the app is launched but not inside the didFinishLaunchingWithOptions. Is that OK? Because my problem is, if I am to do this inside didFinishLaunchingWithOptions, I am not ready to unlock stuff yet because my CoraData stack isn’t ready yet.  

I can move my CoreData setup code into didFinishLaunchingWithOptions as well. But when I do this in the first viewController, I can show a spinner to the user to show something is going on. It is not an awful lot of time but could take a second or two.

What would be  the ‘Best Practice’ in this case please?

Replies

Please? Anyone? 🙂