Posts

Post not yet marked as solved
1 Replies
787 Views
I am developing an app to calculate the Heart rate using SwiftUI. Code is measuring hear rate accurately. But when I took my watch off form my wrist it still showing the heart rate. I have check the apple heart rate app which stop showing the HR as I took of my watch form wrist. swift let healthKitTypes: Set = [ HKObjectType.quantityType(forIdentifier: HKQuantityTypeIdentifier.heartRate)!] healthStore.requestAuthorization(toShare: healthKitTypes, read: healthKitTypes) { _, _ in } let devicePredicate = HKQuery.predicateForObjects(from: [HKDevice.local()]) let updateHandler: (HKAnchoredObjectQuery, [HKSample]?, [HKDeletedObject]?, HKQueryAnchor?, Error?) - Void = { query, samples, deletedObjects, queryAnchor, error in guard let samples = samples as? [HKQuantitySample] else { return } self.process(samples, type: quantityTypeIdentifier) } let query = HKAnchoredObjectQuery(type: HKObjectType.quantityType(forIdentifier: quantityTypeIdentifier)!, predicate: devicePredicate, anchor: nil, limit: HKObjectQueryNoLimit, resultsHandler: updateHandler) query.updateHandler = updateHandler healthStore.execute(query) How Can I achieve this in my application.
Posted Last updated
.