Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fetch/Refresh Health Kit Data Programmatically?

When you open the Health app, it updates it's values from somewhere, but if you don't actually open the app, the Healthkit only seems to update randomly (and very scarsely). For example, Step data objects don't get pulled from (wherever the iOS source comes from) or the 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 querying CoreMotion and making its own Step object that way? (This wouldn't help me much, since I'm actually trying to use the Healthkit to monitor heart rate)

like image 993
Mars Avatar asked Jan 29 '26 16:01

Mars


1 Answers

You cannot control how frequently HealthKit imports data from the Apple Watch. If you want to get live values for readings that come from CoreMotion on the phone itself, such as step counts, you can use HKObserverQuery or HKStatisticsCollectionQuery with an updateHandler.

like image 170
Allan Avatar answered Feb 03 '26 11:02

Allan