What's new in HealthKit
Description: HealthKit is an essential framework that integrates first- and third-party health and fitness data to help people manage their personal health information. Learn about HealthKit’s latest updates, which provide read access to electrocardiograms on Apple Watch and log and track over a dozen new symptoms and their severity. We’ll also go through the latest mobility data types like walking speed and step length to help people monitor and understand their mobility over time.
Tracking Symptoms
30 Symptoms data types have been added to Health Kit this year, they are shown below.
Electrocardiogram (ECG)
ECG samples can now be read as an HKElectrocardiogram
:
/// Represents a collection of voltage measurements.
class HKElectrocardiogram: HKSample {
var classification: HKElectrocardiogram.Classification
var symptomsStatus: HKElectrocardiogram.SymptomsStatus
var averageHeartRate: HKQuantity?
var samplingFrequency: HKQuantity?
var number0fVoltageMeasurements: Int
}
Here's the description and documentation reference for such properties:
classification
: reports whether if the user is in Atrial fibrillation or not.symptomsStatus
: tells us whether the user has any associated a symptom when this ECG was recorded.averageHeartRate
: user’s average heart rate during the ECG.samplingFrequency
: the watch sample frequency during the ECG.numberOfVoltageMeasurements
: the number of measurements that make up this ECG.
If you want individual measurements you have to run the HKElectrocardiogramQuery
:
// Query
class HKElectrocardiogramQuery: HKQuery {
public enum Result {
case measurement(HKElectrocardiogram.VoltageMeasurement)
case error(Error)
case done
}
public convenience init(
_ ecg: HKElectrocardiogram,
dataHandler: @escaping (HKElectrocardiogramQuery, HKElectrocardiogramQuery.Result) -> Void
)
}
Mobility
New set of mobility types:
- walking speed and step length
- walking asymmetry and double support percentage
- stair ascent and descent speed
- six minute walk test