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 applicat
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:
func startCollectingHR(){
guard workoutSession == nil else{return} // Make sure it's not already started
// Also make sure you get the appropriate HealthKit permissions
workoutSession = HKWorkoutSession(activityType: HKWorkoutActivityType.CrossTraining, locationType: HKWorkoutSessionLocationType.Outdoor)
workoutSession!.delegate = self
healthStore.startWorkoutSession(workoutSession!)
print("HR collection started.")
}
Unfortunately, I haven't found any way to get heart rate to reliably live-stream anywhere outside the HealthKit store on the watch.