health-kit

Get and Set info in Medical ID using Healthkit?

你离开我真会死。 提交于 2019-12-02 04:29:08
I am trying to get the information from Medical ID for example Conditions, Medical notes, Allergies & reactions, all that kind of info. I'm using Swift and Health Kit. For the moment the only info that I can get is dateOfBirth, biologicalSex, and bloodType. import UIKit import HealthKit class ViewController: UIViewController { let healthKitStore: HKHealthStore = HKHealthStore() override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. let healthStore: HKHealthStore? = { if HKHealthStore.isHealthDataAvailable() { return

Get most recent data point from HKSampleQuery

吃可爱长大的小学妹 提交于 2019-12-02 04:02:40
I am having trouble getting the latest datapoint for weight using an HKSampleQuery . I have the app permissions set correctly, but HKQuantityTypeIdentifier.bodyMass is not returning the most recent data entry from the Health app. How am I supposed to grab the latest datapoint for body mass using an HKSampleQuery ? The reason I think this is because the 0.0 I set for Weight is what is returning and I am getting no console output on readWeight Edit 1 My code including the debugging process is as follows. public func readWeight(result: @escaping (Double) -> Void) { if (debug){print("Weight")} let

Heart Rate With Apple's Healthkit

依然范特西╮ 提交于 2019-12-02 02:46:46
问题 I'm currently using Healthkit in an app and have no problems getting info for most types, but am having trouble with the Heart Rate. Every time I try to read a sample, I get "0" as a result. I have an Apple Watch, and my Heart Rate gets fed into the Apple Health app, and can visually see it there, so it's not a hardware issue. I only need to display it, no need to write the data back. It asks my permission on first run to allow access to the heart rate, so shouldn't be any issues with that

Better way to run multiple HealthKit sample queries?

大憨熊 提交于 2019-12-01 22:50:10
问题 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, then in the HKSampleQuery's resultsHandler call the second, then in that resultsHandler call the third. That feels kind of -- I don't know -- it feels like I'm missing something. Is there a better way or is the naive approach

Does the AppDelegate initialize when Healthkit wakes my app in the background?

跟風遠走 提交于 2019-12-01 14:26:45
I use the code below to have my app detect updates to HealthKit data in the background. Will the init method of my AppDelegate be called when this code is run in the background? What methods in the AppDelegate will be called? If someone can provide documentation about the application lifecycle of background code, that will be much appreciated! [healthStore enableBackgroundDeliveryForType:type frequency:HKUpdateFrequencyHourly withCompletion:^(BOOL success, NSError *error) { if (success) { HKObserverQuery *observerQuery = [[HKObserverQuery alloc] initWithSampleType:type predicate:nil

Does the AppDelegate initialize when Healthkit wakes my app in the background?

纵然是瞬间 提交于 2019-12-01 12:51:40
问题 I use the code below to have my app detect updates to HealthKit data in the background. Will the init method of my AppDelegate be called when this code is run in the background? What methods in the AppDelegate will be called? If someone can provide documentation about the application lifecycle of background code, that will be much appreciated! [healthStore enableBackgroundDeliveryForType:type frequency:HKUpdateFrequencyHourly withCompletion:^(BOOL success, NSError *error) { if (success) {

HKMetadataKeyTimeZone is always nil for health data which is created by apple's Health App - HealthKit - iOS

a 夏天 提交于 2019-12-01 10:42:34
I'm reading user's health data using HealthKit. Trying to get the timezone information from Health data to identify on which exact timezone the health activity has happened. For this, I'm depending on 'HKMetadataKeyTimeZone' key from HealthKit metadata. But the value for 'HKMetadataKeyTimeZone' key is always nil even for the health data that is automatically recorded by Apple's Health app. Same problem for the data that is manually entered on Apple's Health app. So is there any other key/way that can give the time zone information for each sample? or Apple's health app is not at all logging

How to get the most recent Weight entry from HealthKit data

走远了吗. 提交于 2019-12-01 06:53:38
How can I get the most recent weight entry from healthkit data? My code is only returning the first weight entry ever recorded. Is is possible to get only the last entry recorded without specifying a date range? Here is my code that gets the first entry: class HealthStore { private let healthStore = HKHealthStore() private let bodyMassType = HKSampleType.quantityType(forIdentifier: .bodyMass)! func authorizeHealthKit(completion: @escaping ((_ success: Bool, _ error: Error?) -> Void)) { if !HKHealthStore.isHealthDataAvailable() { return } let readDataTypes: Set<HKSampleType> = [bodyMassType]

iOS app reject because of healthkit

纵然是瞬间 提交于 2019-12-01 04:33:43
I am using HealthKit in my app to read users daily steps data and for that I enable HealthKit in my app. I uploaded app without NSHealthShareUsageDescription and NSHealthUpdateUsageDescription key in info.plist . Apple rejected the app as follow and says this both key must be in info.plist . NSHealthUpdateUsageDescription - Read your daily steps data for calorie count data NSHealthShareUsageDescription - Share workout data with apps. I added that key and upload again. now app rejected with this reason. Design - 4.2.1 Your app uses the HealthKit or CareKit APIs but does not indicate integration

HealthKit data inaccessible in background

試著忘記壹切 提交于 2019-12-01 03:42:13
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 phone is locked. This means your app may not be able to access the store when it is launched in the background. Any workaround to access data in the background? Is the HKObserverQuery the only way to get data in the background