简体   繁体   中英

How to update iOS app with Apple Watch heart rate via healthkit? (HealthKit sync)

My watch app is easily capable of reading new heart rate data from HealthKit's new updateHandler in HKAnchoredObjectQuery.

Trouble is, the health store that the phone app observes seems to be unsynchronized with the watch.

Suspending the app and resuming it will sometimes prompt HealthKit to do (what seems to be) a synchronization between the watch's health store and the phone's store. I don't know why that is.

What I need is some way to continuously re-sync the health store between devices. If I simply send the newest heart rate data from the watch to the phone app with WatchConnectivity, then I can indeed get the data I need for display, but then if I submit such data to the store, I'll get duplicates when the watch's store DOES sync.

This is a major problem because it ruins HealthKit as a reliable single location to read and write health data.

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

There is no way for your app to force the HealthKit synchronize data between the watch and the phone. What you are already doing with WatchConnectivity is the recommended approach to displaying live data from the watch.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM