FAQ Database Discussion Community
ios,health-kit
I have a scenario where I need to retrieve multiple sets of data from HealthKit -- body temperature, weight, and blood pressure. I need all 3 before I can continue processing because they're going to end up in a PDF. My naive first approach is going to be run one,...
ios,objective-c,health-kit
Ok, so the property workoutActivityType of the HKWorkout returns a NSInteger. Here is a list with the activities: workoutActivityType list For now, I will create a plist and look for the activity name when I get the integer. But it seems a little odd to have to go through this....
ios,swift,closures,health-kit
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,...
ios,health-kit
Im finding that asking for a sum of, for example, dietary calories from HealthKit will return a value which automatically subtracts entries made from my own app. That is great and is the behaviour I want, but this doesn't happen all the time - sometimes it includes entries I have...
ios,background-process,health-kit,hkhealthstore
I want to pull HealthStore data in the background using background fetch but I keep getting an error: Error Domain=com.apple.healthkit Code=6 "Protected health data is inaccessible" UserInfo=0x17026fdc0 {NSLocalizedDescription=Protected health data is inaccessible}. Apple states: Because the HealthKit store is encrypted, your app cannot read data from the store when the...
objective-c,import,core-motion,health-kit
I'm trying to count the steps of user using CoreMotion, HealthKitand everything that is needed. At first I tried it with Swift (I'm not good with swift) and imported these two files: import HealthKit import CoreMotion And when I declared CMStepCounter it successfully declared it, means the type was found....
ios,xcode,swift,health-kit
I'm following some tutorials on HealthKit using swift, one of the tutorials I'm following is how to retrieve some data from the HealthKit such as weight, height age. The tutorial shows how to retrieve the most recent record for each them, the following codes shows that: func readMostRecentSample(sampleType:HKSampleType , completion:...
swift,health-kit
I have a little problem grasping HealthKit. I want to get heart rate from HealthKit with specific time. I have done this in the past (until I noticed that I couldn't fetch data when the phone was locked) func retrieveMostRecentHeartRateSample(completionHandler: (sample: HKQuantitySample) -> Void) { let sampleType = HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierHeartRate) let...
ios8,apple-watch,core-motion,health-kit
When you open the Health app, it updates it's values from somewhere, but if you don't actually open the app, the Healthkit only seems to update randomly (and very scarsely). For example, Step data objects don't get pulled from (wherever the iOS source comes from) or the Apple Watch until...
ios,watchkit,apple-watch,health-kit
I have read documents that said : All the data Apple Watch collects about your heart rate is then transferred automatically to the Health app on your iPhone. I have not found any Information about steps and calories. Whether it store in apple watch local storage or in Health App....
ios,swift,health-kit,hkhealthstore
I am trying to access HK in my iOS app. I have everything set up, or so I thought, properly. But when it runs I get a "-[__NSArrayI _allowAuthorizationForReadingWithEntitlements:]: unrecognized selector sent to instance 0x7f99badc54f0" error and I'm not sure why. I followed Ray Wenderlichs post, and even his app...
ios,health-kit
For HKQuantityType like steps I can use HKStatisticsCollectionQuery to get sum of all steps on the interval, in my case day, without worrying about deduplicate date since HealthKit handle that for me. But Sleep Analytics is HKCategoryType and from what I know HKStatisticsCollectionQuery doesn't support this type. This mean I...
ios,objective-c,health-kit
I have this code that is trying to do a background fetch for HealthKit data. The code works fine when I first run the app, but if I manually perform a background fetch (using the debug command), I get an exception thrown and an error that says reason: 'this request...
ios,objective-c,iphone,health-kit
So, I though I was finally getting the hang of iOS development and then I encounter this.... So I am trying to create a health app that uses health kit to import some of the users data and then process it in various ways and so on. Upon performing the...
objective-c,swift,health-kit
so i've come across this strange issue. I want to extract a NSMassFormatterUnit from a HKUnit so that i can get a string value out of it. It seems that the method HKUnit.massFormatterUnitFromUnit does not accept kilograms, or any metric-prefixed version of "grams" HKUnit.massFormatterUnitFromUnit(HKUnit(fromString: "kg")) // Fails HKUnit.massFormatterUnitFromUnit(HKUnit(fromString: "lb")) //...
ios,health-kit,ios-extensions
I am making a iWatch app where I need to show data from healthkit. is it possible to access healthkit APIs from iWatch extension?
health-kit,hkhealthstore
As you may know, when the iPhone is locked, the HealthKit data gets encrypted, but data may still be added to the HealthStore by the phone (eg. When you are walking, step count will be added even if the phone is locked) I tried using a HKObserverQuery to check for...
ios,swift,uiviewcontroller,health-kit
In my app I ask for HealthKit access and that works fine. I get permission to read the step count and flights climbed. After the permissions are authorized I want to send the user to a new ViewController. This works fine but the elements in that ViewController are shown after...
ios,objective-c,xcode6,health-kit
I have determined authorization before actually trying to save any data or do anything with it. The error is happening at the moment of query: HKSampleQuery *query = [[HKSampleQuery alloc] initWithSampleType:foodType predicate:predicate limit:HKObjectQueryNoLimit sortDescriptors:nil resultsHandler:^(HKSampleQuery *query, NSArray *results, NSError *error){ ... } Yes, I have read apple documentation that says:...
ios,iphone,xcode,swift,health-kit
Im trying to display the daily amount of steps the user takes. But is don't really know how to manage this. I already got this code: let endDate = NSDate() let startDate = NSCalendar.currentCalendar().dateByAddingUnit(.CalendarUnitMonth, value: -1, toDate: endDate, options: nil) let weightSampleType = HKSampleType.quantityTypeForIdentifier(HKQuantityTypeIdentifierStepCount) let predicate = HKQuery.predicateForSamplesWithStartDate(startDate, endDate: endDate,...
ios,objective-c,health-kit
Blood glucose values were added back in Health in iOS 8.2: https://support.apple.com/en-us/HT203113 How do I construct a HealthKit HKUnit for mmol/L (millimoles per liter) for Blood Glucose values? The following both throw exceptions: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unable to parse factorization string... HKUnit *mmolPerL = [HKUnit...
ios,swift,health-kit
I've inserted some glucose data in my device health kit app, and now trying to retrieve these inserted data but I'm getting this error: 2015-05-17 11:33:08.056 HKTutorial[687:125911] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Attempt to convert incompatible units: mg/dL, mol<180.1558800000541>' This the method code I'm using to...