1

I've built an app that gathers workout data from healthkit (from external sources) that is saved on a server so that other users can view the workouts in a feed. I initially set up the query to be handled when the app was opened, but then realised that the database only gets updated when the user opens the app which causes issues if they don't open the app for a week.

I've looked into a solution, but it seems as though apple only allows you to access healthkit data when the users phone is unlocked. Is there a way to run a healthkit query whenever a new workout is added to healthkit, that I can deal with in the background?

Khledon
  • 193
  • 5
  • 23

1 Answers1

3

HealthKit data cannot be reliably read when the device is locked; the data is in fact encrypted, along with the device keychain, when locked. In some cases you may be able to write data while the store is locked.

One solution is prompting the user to re-open the app periodically for sync.

emma ray
  • 13,336
  • 1
  • 24
  • 50
  • 1
    To promote re-open the app or to get a few seconds in background, local notifications and silent push notifications can be helpful. – Kamran Apr 28 '19 at 09:52