I am using iOS 9 beta 4 and watchOS 2 beta 4.
I can't seem to get any heart rate data when the watch screen turns black (locks). I will get a call to applicationWillResignActive
and then the heart rate data just stops.
It seems that the sensor is deactivating after some time as well (not green anymore), when the screen locks.
Anyone else seeing this behavior? I can post my code for initing the WorkoutSession if anyone else getting heart rate data when the screen on the watch is locked.
I noticed similar behaviour and found that the first workout session would run as intended, but subsequent ones would only run when the watch face was active. I solved the problem by resetting HKWorkoutSession once the session was completed.
The watch app platform is designed to totally disable your code shortly after applicationWillResignActive(). However with an HKWorkoutSession active, the watch should record heart rate data to the HK store in the background (as long as another watch app doesn't start a new one and cancel yours).
This is roughly what I do to start heart rate collection:
Unfortunately, I haven't found any way to get heart rate to reliably live-stream anywhere outside the HealthKit store on the watch.
Starting in watchOS 3.0 you can add the
WKBackgroundModes
entry with theworkout-processing
value to the extension's Info.plist.From the docs: