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.
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)")
)
}
Post
Replies
Boosts
Views
Activity
Hi guys,I am finding that WCSession.default.transferUserInfo is not working on the simulator for XCode 11.5. When I run the simulator, nothing happens.I have tried downgrading the WatchOS to 5.3 with an iPhone running 12.4, but I am still not able to use transferInfo with the simulator.When I plug in an actual device, transferInfo works fine.Is there something I am doing wrong with the simulator?Thanks.