healthkit

iOS get heart rate from Apple Watch in near real time

二次信任 提交于 2019-12-17 18:27:27
问题 I need to make an app that records heart rate data in near real time and send this data to a server as soon as possible. First I took this approach: Watch os 2.0 beta: access heart beat rate In fact it is working fine. There is new heart rate data in the HealthKit every five seconds. But now I have the problem that I can't sync that with a server. My first approach was the Watch app. The watch was sending data to a server. That doesn't work because as soon as the screen turns black on the

dispatch_group_leave crash in swift

笑着哭i 提交于 2019-12-13 12:58:41
问题 This happens very rarely. Here is the last line of the stack trace: 0 libdispatch.dylib 0x0000000197a85a9c dispatch_group_leave + 48 dispatch_group_leave is called in a complete closure which is invoked like this: dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), { () -> Void in let query = HKStatisticsCollectionQuery(quantityType: quantityType, quantitySamplePredicate: nil, options: statisticOptions, anchorDate: anchorDate, intervalComponents: interval) query

How to filter “active” HeartRate from HealthKit iOS using predicate?

空扰寡人 提交于 2019-12-13 03:18:06
问题 I am trying to fetch Heart Rate Data from HealthKit iOS by putting filter using HKQuery.predicateForObjects By using the following code: let predicate = HKQuery.predicateForObjects(withMetadataKey: HKMetadataKeyHeartRateMotionContext, allowedValues: ["active"]) var interval = DateComponents() interval.day = 1 let query = HKStatisticsCollectionQuery(quantityType: type, quantitySamplePredicate: predicate, options: [.discreteAverage], anchorDate: startDate, intervalComponents:interval) query

Save/Delete to HealthKit With WatchKit and Widget (Today Extension)?

淺唱寂寞╮ 提交于 2019-12-13 02:54:32
问题 Here is a question that I know has an answer since I see apps that do this functionality. I have tried (writing directly, using background fetch) but nothing works. I found an app currently on the app store with the functionality that I am looking for. With Background Fetch set to OFF and main app NOT running in background. I go to the Widget and add an item. I open HealthKit and I see the data there as expected. I would like to do the same for my app. I would like my today extension (widget)

HealthKit: Workout saved on iPhone not visible in Activity App

笑着哭i 提交于 2019-12-12 10:39:27
问题 Using HealthKit, I am saving A Workout Corresponding Active Energy Samples Corresponding Walk/Run distance samples I'm running the same code on the apple watch and on the iPhone. When I'm saving on the iPhone I can select the workout and samples in my iPhone App I can see the workout and samples in the iPhone Health App The workout and samples are not in the iPhone activity app (bad) When I'm saving on the apple watch I can select the workout and samples in my iPhone App I can see the workout

How to read healthKit Heartrate data?

六月ゝ 毕业季﹏ 提交于 2019-12-12 03:40:08
问题 I know this questions been asked, but hasn't really been answered. I've tried things from threads like this: Heart Rate With Apple's Healthkit I tried converting this from Objective-C to Swift but didn't work. My question is, what's the best way to read heart rate data from health kit. I want to be able to read every heart rate measurement from the time it started taking them, and I want to be able to see the time/day stamps of said measurements. I asked for permission here: import Foundation

HKAnchoredObjectQuery not returning reliably in background

北城余情 提交于 2019-12-12 03:38:05
问题 I'm trying to make my app synchronize HealthKit data with our database whenever new data input is observed. Despite some ambiguity in the logic I believe I've managed to enable background delivery for the sample types and have the observers react when needed. However, in the observer's updatehandler I need to create an HKAnchoredObjectQuery for fetching the most recent results from HealthKit, but these queries don't return reliably when my app is running in the background. Often when I add

Query to Healthstore for Resting Heart Rate not returning any values

最后都变了- 提交于 2019-12-11 16:59:02
问题 I have no trouble getting heart rates during a workout with the code below, however when querying my own heart rates (and I know there are values in the Health app) I am getting no results? Am I doing anything wrong? func getuserRestingHeartRate(completion: @escaping (HKQuantitySample) -> Void) { guard let restingHeartRateSampleType = HKSampleType.quantityType(forIdentifier: .restingHeartRate) else { print("Resting Heart Rate Sample Type is no longer available in HealthKit") return } //1. Use

Xamarin.iOS Why is HKAnchoredObjectQuery inactive then deactivated when debugging on device?

冷暖自知 提交于 2019-12-11 15:35:47
问题 I am stumped. I have code that works perfectly on the iOS simulator but when I debug on an actual device the HKAnchoredObjectQuery object is inactive before it runs: <HKAnchoredObjectQuery:0x2816e8780 inactive> And then deactivated after it executes in the results handler: <HKAnchoredObjectQuery:0x2816e8780 deactivated> My code looks like this: var query = new HKAnchoredObjectQuery(type, compoundPredicate, lastAnchor, nuint.MaxValue, new HKAnchoredObjectResultHandler2( (q, results, anchor,

Can I save value in a completion Handler

浪尽此生 提交于 2019-12-11 13:26:19
问题 here is the thing, I wants to save the today steps into Core Data in completionHandler. But while I load this value,the complier shows it a nil. any solution? func fetchDataOfQuantityType(startDate: NSDate, endDate: NSDate, quantityType: HKQuantityType, completion:((NSArray, NSError!) -> Void)!) { // initial a predicate with startDate and endDate let predicate = HKQuery.predicateForSamplesWithStartDate(startDate, endDate: endDate, options: HKQueryOptions.StrictStartDate) // initialize a