How to update Apple Watch heart rate iOS app through healthkit? (HealthKit Sync)

My watch app can easily read new heart rate data from the HealthKit new updateHandler in HKAnchoredObjectQuery.

The problem is that the health store that the phone application is watching does not seem to be in sync with the clock.

Pausing the application and resuming it sometimes prompts HealthKit to (apparently) synchronize between the clock store and the phone store. I do not know why this is so.

I need some way to constantly reconfigure the health store between devices. If I just send the latest heart rate data from the watch to the phone app with WatchConnectivity, then I can really get the data I need to display, but if I send this data to the store, I will get duplicates when the store watches DOES sync.

This is a serious problem because it destroys HealthKit as a reliable one place to read and write health data.

Edit: Apple Apple Error Report https://openradar.appspot.com/radar?id=5033927626457088

+5
source share
1 answer

Your application does not have the ability to force synchronization of HealthKit data between the clock and the phone. What you are already doing with WatchConnectivity is the recommended approach to displaying live data from a watch.

+2
source

All Articles