Apple's Documentation Class Reference for HKHealthDataStore states that observer queries should be setup within the AppDelegate.
"set up all your observer queries in your app delegate’s application:didFinishLaunchingWithOptions: method. By setting up the queries in application:didFinishLaunchingWithOptions:, you ensure that the queries are instantiated and ready to use before HealthKit delivers the updates."
When a user first opens my app, I need to take them through an Onboarding flow, which involves requesting HealthKit Authorization Permissions, before setting up Observer Queries and querying some initial data. My app is entirely based around Observer Queries, so I need to be able to register for background updates during the first launch of my app.
I'm unsure how I can do this from the AppDelegate? I can't just request HealthKit Authorization immediately the first time a user downloads and opens my app, before they see anything else? Or request Authorization and then tell the user to quit my app, and re-open it so that I can setup observer queries in the App Delegate the second time.
Am I misunderstanding the documentation? Or approaching this wrong?
Any help or suggestions would be greatly appreciated.
Thank you