Fetch / update health set data programmatically?

When you open the Health app, it updates its values ​​somewhere, but if you don't actually open the app, then the Healthkit only seems to be updated randomly (and very slightly). For example, Step data objects are not retrieved from (wherever the iOS source is) or Apple Watch until you actually open the Health app.

Is there a way to update the information programmatically? Or is the Health app itself just asking for CoreMotion and making its own Step object that way? (This would not help me, since I am actually trying to use Healthkit to monitor my heart rate)

+3


source to share


1 answer


You have no control over how often HealthKit imports data from your Apple Watch. If you want to get live values ​​for display that come from CoreMotion on the phone itself, for example, the number of steps, you can use HKObserverQuery

or HKStatisticsCollectionQuery

with updateHandler.



+2


source







All Articles