healthkit

How to get Heartrate data from Apple's Healthkit?

Deadly 提交于 2020-01-03 04:40:09
问题 I am trying to read Heartrate data from Healthkit. I am not able to read that data. I have gone throught this link. Please help me guys..Thank you. 回答1: I managed to read the heart rates from HelathKit using HKSampleQuery. I start reading it from the beginning of the day till 'now'. I also used this link Here is my function and I call it by pressing a button: - (void)readHeartRateWithCompletion:(void (^)(NSArray *results, NSError *error))completion { //get the heart rates NSDate *now =

How do I download Healthkit step and distance data?

放肆的年华 提交于 2020-01-02 20:10:11
问题 I would like to download the step and distance data collected by the motion processor in the IPhone 5S (and later), and available in Apple's HealthKit, for analysis. What's the easiest/best way to do this? And clarifying (after new answers): is there any way to do it without writing a new iOS app? Are there any existing apps that provide the data, and/or any iCloud API that provides access. 回答1: I'm not sure it can help you but this is how I get steps + (void)readUsersStepFromHK:(NSDate*

For iOS healthkit how to save systolic and diastolic blood pressure values?

≯℡__Kan透↙ 提交于 2020-01-02 06:22:12
问题 Here is code for saving blood pressure data in health kit HKUnit *BPunit = [HKUnit millimeterOfMercuryUnit]; HKQuantity *BPSysQuantity = [HKQuantity quantityWithUnit:BPunit doubleValue:150.0]; HKQuantityType *BPSysType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierBloodPressureSystolic]; HKQuantitySample *BPSysSample = [HKQuantitySample quantitySampleWithType:BPSysType quantity:BpsysQuantity startDate:now endDate:now]; [self.healthStore saveObject:BPSysSample

HealthKit HKAuthorizationStatus for reading data

五迷三道 提交于 2020-01-01 04:08:05
问题 I'm using HealthKit to read certain types of information. I'm specifically not asking for write functionality. The problem comes in when trying to detect if the user has allowed a certain Health type to be read. I believe the intended way to do this is using an HKHealthStore's authorizationStatusForType method, but this is only returned denied or unknown. It is only returning authorized for write types. Has anyone found a way to use this method for reading or another work around?

iOS : Use of HKObserverQuery's background update completionHandler

自闭症网瘾萝莉.ら 提交于 2019-12-31 10:56:56
问题 HKObserverQuery has the following method that supports receiving updates in the background: - initWithSampleType:predicate:updateHandler: The updateHandler has a completionHandler which has the following documentation: This block is passed to the update handler. You must call this block as soon as you are done processing the incoming data. Calling this block tells HealthKit that you have successfully received the background data. If you do not call this block, HealthKit continues to attempt

How to get the most recent Weight entry from HealthKit data

余生颓废 提交于 2019-12-30 10:04:29
问题 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

HealthStore enableBackgroundDelivery when screen is locked

只愿长相守 提交于 2019-12-30 01:32:35
问题 Hello I'm trying to setup the health store observer with background delivery enabled. My problem is that it won't deliver anything when the screen is locked. I have simplified my code for this question to get to the point :) I have HealthKit in my plist and I have accepted healthStore type step count. Everything is fine when the app is open and when the screen is not locked. But when the screen is locked I don't get any observations. For test purpose the frequency is set to immediate. My code

Healthkit background delivery when app is not running

雨燕双飞 提交于 2019-12-27 11:04:39
问题 Can HealthKit background delivery launch the application if is not running? Particularly in a terminated state? 回答1: After a full day of testing (iOS 9.2) I can confirm that HealthKit background delivery DOES WORK in all of the following application states: background (in background and executing code), suspended (in background but not executing code), terminated (force-killed by the user or purged by the system). Keep in mind : part 1 Some HealthKit data types have a minimum update frequency

HKSampleQuery will only return values from past 7 days?

谁说胖子不能爱 提交于 2019-12-25 01:54:07
问题 This is a WatchOS App. Through testing, it appears as though this code will only return any bodyweight values that I manually add to the health app that are less than 1 week old. Is this intended? Ways around? func getUserBodyMass(completion: @escaping (HKQuantitySample) -> Void) { guard let weightSampleType = HKSampleType.quantityType(forIdentifier: .bodyMass) else { print("Body Mass Sample Type is no longer available in HealthKit") return } //1. Use HKQuery to load the most recent samples.

HealthKit not up to date

独自空忆成欢 提交于 2019-12-23 21:24:02
问题 I'm using HealthKit in one of my apps I may be using it wrong, but I have found that when reading steps (I haven't tried with other data), new step data isn't returned in my query and I need to open the Health app, and then open my app for that new information to be returned by the query. if([HKHealthStore isHealthDataAvailable]) { HKHealthStore *healthStore = [[HKHealthStore alloc] init]; // Query for step data HKQuantityType *stepType = [HKObjectType quantityTypeForIdentifier