As you may know, when the iPhone is locked, the HealthKit data gets encrypted, but data may still be added to the HealthStore by the phone (eg. When you are walking, step count will be added even if the phone is locked)
I tried using a HKObserverQuery to check for updates in the HealthStore for the number of steps. But as expected, it failed when the phone the phone is locked.
Is there any alternate way to detect changes in the StepCount data in the HealthStore (By using only the HealthKit functionalities. Not a combination of CoreMotion and HealthKit etc.)