Can I get health data from a background service of given date and time in my local db allover the day.

1. I created a timer thread which run on background.

2. Check the interval if interval is more than 10 min.

3. It query the local db pick date and time.

4. Check if current time is greater than the received time, query the healthkit/ perdometer data of given time and send to my server.


Problem: Sometimes it runs great but after few hours or i open another app then i think os kill my thread and stops service.

Please help me with the best way to my requirement.


Thank you

Replies

Note that HealkthKit read does not work when the iPhone is locked.

If you're still looking for some details, Chepiok asked a similar question and I replied at length here: https://forums.developer.apple.com/thread/126051