Global Variable

HKQuantityTypeIdentifierHeartRate

A quantity sample type that measures the user’s heart rate.

Declaration

const HKQuantityTypeIdentifier HKQuantityTypeIdentifierHeartRate;

Discussion

These samples use count/time units (described in HKUnit) and measure discrete values (described in HKStatisticsQuery).

Heart rate samples may include motion context information, which is stored as metadata using the HKMetadataKeyHeartRateMotionContext key. The value of this key is an NSNumber object that contains a HKHeartRateMotionContext value.

The motion context gives additional information about the user’s activity level when the heart rate sample was taken. Apple Watch uses the following guidelines when setting the motion context:

  1. If the user has been still for at least 5 minutes prior to the sample, the context is set to the HKHeartRateMotionContextSedentary value.

  2. If the user is in motion, the context is set to the HKHeartRateMotionContextActive value.

You can add motion context to the metadata of any heart rate samples that you create. This means other apps may also save heart rate samples with (or without) the HKMetadataKeyHeartRateMotionContext metadata key.

Note that not all heart rate samples have a motion context. For example, if Apple Watch cannot determine the motion context, it creates samples without a HKMetadataKeyHeartRateMotionContext metadata key. In addition, heart rate samples recorded by an Apple Watch (1st generation) or by a device running watchOS 3 or earlier do not have the motion context metadata key. Treat these samples as if they used the HKHeartRateMotionContextNotSet motion context.

Topics

Metadata Keys

HKMetadataKeyHeartRateSensorLocation

The location where a particular heart rate reading was taken.

HKMetadataKeyHeartRateMotionContext

The user’s activity level when the heart rate sample was measured.

See Also

Vital Signs

HKCategoryTypeIdentifierLowHeartRateEvent

A category sample type for low heart rate events.

HKCategoryTypeIdentifierHighHeartRateEvent

A category sample type for high heart rate events.

HKCategoryTypeIdentifierIrregularHeartRhythmEvent

A category sample type for irregular heart rhythm events.

HKQuantityTypeIdentifierRestingHeartRate

A quantity sample type that measures the user’s resting heart rate.

HKQuantityTypeIdentifierHeartRateVariabilitySDNN

A quantity sample type that measures the standard deviation of heartbeat intervals.

HKQuantityTypeIdentifierWalkingHeartRateAverage

A quantity sample type that measures the user’s heart rate while walking.

HKDataTypeIdentifierHeartbeatSeries

A series sample containing heartbeat data.

Beta
HKQuantityTypeIdentifierOxygenSaturation

A quantity sample type that measures the user’s oxygen saturation.

HKQuantityTypeIdentifierBodyTemperature

A quantity sample type that measures the user’s body temperature.

HKCorrelationTypeIdentifierBloodPressure

Blood pressure correlation types combine a systolic sample and a diastolic sample into a single blood pressure reading.

HKQuantityTypeIdentifierBloodPressureSystolic

A quantity sample type that measures the user’s systolic blood pressure.

HKQuantityTypeIdentifierBloodPressureDiastolic

A quantity sample type that measures the user’s diastolic blood pressure.

HKQuantityTypeIdentifierRespiratoryRate

A quantity sample type that measures the user’s respiratory rate.

HKQuantityTypeIdentifierVO2Max

A quantity sample that measures the maximal oxygen consumption during incremental exercise.