Hi guys,
Is there a way to detect if a body is present to determine whether or not to show a heart rate?
I am finding that when I take the watch off, the heart rate sensor keeps returning values. I want to show "-" when the watch is taken off.
Below is the function I am using to get the last heart rate.
Thanks.
Is there a way to detect if a body is present to determine whether or not to show a heart rate?
I am finding that when I take the watch off, the heart rate sensor keeps returning values. I want to show "-" when the watch is taken off.
Below is the function I am using to get the last heart rate.
Thanks.
Code Block private func process(_ samples: [HKQuantitySample], type: HKQuantityTypeIdentifier) { print("I am in the process func") // variable initialization var lastHeartRate = 0.0 // cycle and value assignment guard let sample = samples.first else{ return } if type == .heartRate { lastHeartRate = sample.quantity.doubleValue(for: heartRateQuantity) } self.value = Int(lastHeartRate) hrLabel.setText(String(value)) print("****The lastHeartRate is \(lastHeartRate)") ) }