Initiate Sync Between Health Stores on Watch and Phone

Originator:tealShift
Number:rdar://22646379 Date Originated:10/10/2015
Status:Open Resolved:
Product: Product Version:
Classification: Reproducible:
 
My watch app is easily capable of reading live 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, but it suggests there is some internal initiation for the sync.
What I need is a method in the API that simply asks HealthKit to do that. 

This is a major problem because it renders HealthKit an unreliable single location to read and write health data.

Steps to Reproduce:
1) Use an HKAnchoredObjectQuery on the watch for collecting heart rate, same as in the WatchOS2 presentation demo.

2) Implement the same query on the companion app on the iPhone. Display the latest heart rate like the watch app.

3) Run the watch app in the XCode simulator. Open the companion app for displaying what the phone sees as "live heart rate."

Expected Results:
I don't necessarily expect the steps above to achieve live heart rate on the phone, but an API method to periodically re-sync the Health Store would.

Actual Results:
The Watch app returns new heart rate data while the companion app fails. If you open the Health app on the phone, and then return to the companion app, it will re-sync and show the latest heart rate momentarily.

Version:
iOS SDK 9.0 GM

Comments

The watch app in this case is optional for the purposes of replication right?

You should be able to get the updated rate on the companion app regardless of having a watch app running, correct?

By roberto.andrade at Dec. 10, 2015, 7:15 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!