Hi!
Currently I am facing an issue I don't fully understand.
I have to get the steps and distanceWalkingAndRunning and sync it to the backend periodically for which I have registered a BGTaskScheduler and created a request to trigger it every 15 minutes.
I understand that it's just a request to trigger it every 15 minutes, in reality the OS decides when to run it, no earlier than the set time.
For debugging purposes, one can trigger the task manually which I tried and succeeded. Works as expected.
App is running, the task gets registered and scheduled, I pause the app and send the command to trigger the task.
Upon resuming the app, my task gets executed, the HealthKit query goes through and submits the correct values to the backend.
Now to the issue. If I run the app normally, and wait for the task to get executed, for some reason the HealthKit query always returns 0, ergo syncing wrong values to the backend.
It's hard to debug this case, I have all the permission I need to read the data and works properly when run manually.
Either i need a special entitlement or this is a bug or I am missing something (most likely?). I hope to get some help here.