HealthKit Constants

Overview

This document defines constants in the HealthKit framework that are not associated with a particular class.

Topics

Metadata Keys and Values

Predefined keys and values. Use these constants to store metadata so that it can be shared with other apps.

Metadata Keys

A set of predefined keys for adding metadata to HealthKit objects. Use these keys to facilitate sharing data between apps. You can also create your own custom keys to give HealthKit objects additional app-specific data.

HKBodyTemperatureSensorLocation

Constants that indicate where on the body a temperature reading was taken.

HKHeartRateSensorLocation

Constants that indicate where on the body the heart rate sensor is located.

HKHeartRateMotionContext

Values that indicate the user’s level of activity when the heart rate sample was measured.

HKWeatherCondition

Constants that indicate a type of weather.

Type Identifiers

Constant values used to specify both the type of sample (quantity, category, characteristic, correlation, or workout) and the value being measured. Use these constants to create HKObjectType objects.

Body Measurements

Identifiers for quantity types based on body measurements.

Fitness Identifiers

Identifiers for quantity types that measure fitness data.

Vital Signs Identifiers

Identifiers for quantity types that measure the user’s vital signs.

Results Identifiers

Identifiers for quantity types that measure results data.

Nutrition Identifiers

Identifiers for quantity types that measure the nutritional data of food. When entering food data, combine multiple nutrition samples into a single correlation object. For more information, see HKCorrelationTypeIdentifierFood.

UV Exposure Identifier

An identifier for quantity types that measure the user’s exposure to ultraviolet (UV) radiation.

Category Type Identifiers

Identifiers for category types.

Characteristics Type Identifiers

Identifiers for characteristic types.

Correlation Type Identifiers

Identifiers for correlation types.

Workout Type Identifier

An identifier for workout types.

Document Type Identifier

An identifier for continuity of care document (CDA) types

Workout Constants

Constants used to define workout samples and workout sessions.

HKWorkoutActivityType

The type of activity performed during a workout.

HKWorkoutSessionState

A workout session’s state.

HKWorkoutSessionLocationType

A constant indicating whether the workout session takes place indoors or outdoors.

Other HealthKit Constants

Other constants used by Health Kit.

Health Kit Error Domain

Constant for the HealthKit error domain.

HKErrorCode

Error codes that may be returned when calling HealthKit methods.

HKUpdateFrequency

Constants that determine how often the system will launch your app in response to changes to HealthKit data. For more information, see HKObserverQuery.

HKAuthorizationStatus

Constants indicating the authorization status for a particular data type.

HKFitzpatrickSkinType

Categories representing the user’s skin type based on the Fitzpatrick scale. The Fitzpatrick scale is a numerical classification for skin color based on the skins response to sun exposure in terms of the degree of burning and tanning.

HKCategoryValueSleepAnalysis

Categories used when analyzing sleep samples.

HKCategoryValueAppleStandHour

Categories used to indicate whether the user stood during the sample’s duration.

HKCategoryValueCervicalMucusQuality

Categories used to represent the user’s cervical mucus quality. These values are ordered from least-fertile (Dry) to most-fertile (EggWhite).

HKCategoryValueOvulationTestResult

Categories used to represent the result of an ovulation home test.

HKCategoryValueMenstrualFlow

Constants indicating the amount of menstrual flow for a given sample.

HKCategoryValue

Miscellaneous category values.

HKBiologicalSex

Constants indicating the user’s sex. A person's sex is a combination of bodily characteristics including: chromosomes, hormones, internal and external reproductive organs, and secondary sex characteristics.

HKBloodType

Constants indicating the user’s blood type.

HKWheelchairUse

Constants indicating the user’s wheelchair use.

Constants

HKAnchoredObjectQueryNoAnchor

An anchor that returns all of the matching samples currently in the HealthKit store.

HKDetailedCDAValidationErrorKey

A key for accessing validation error information from an NSError object’s userInfo dictionary.

HKDevicePropertyKeyFirmwareVersion

The device’s firmware version.

HKDevicePropertyKeyHardwareVersion

The device’s hardware version.

HKDevicePropertyKeyLocalIdentifier

A unique identifier for the device on the hardware running the app. For more information, see localIdentifier.

HKDevicePropertyKeyManufacturer

The device’s manufacturer.

HKDevicePropertyKeyModel

The device’s model.

HKDevicePropertyKeyName

The device’s name.

HKDevicePropertyKeySoftwareVersion

The device’s software version.

HKDevicePropertyKeyUDIDeviceIdentifier

The device’s UDI Device Identifier.

HKMetadataKeyLapLength

A key that indicates the length of a lap during a workout.

HKMetadataKeySwimmingLocationType

A key that indicates the location for a swimming workout.

HKMetadataKeySwimmingStrokeStyle

A key that indicates the predominant stroke style for a lap of swimming.

HKObjectQueryNoLimit

A value indicating that the query returns all the matching samples in the HealthKit store.

HKPredicateKeyPathCDAAuthorName

The key path for accessing the author’s name inside a predicate format string.

HKPredicateKeyPathCDACustodianName

The key path for accessing the custodian’s name inside a predicate format string.

HKPredicateKeyPathCDAPatientName

The key path for accessing the patient’s name inside a predicate format string.

HKPredicateKeyPathCDATitle

The key path for accessing the document’s title inside a predicate format string.

HKPredicateKeyPathCategoryValue

The key path for the category sample’s value.

HKPredicateKeyPathCorrelation

The key path for accessing the object’s correlation inside a predicate format string.

HKPredicateKeyPathDateComponents

A key path for the summary’s date components.

HKPredicateKeyPathDevice

The key path for accessing the object’s device inside a predicate format string.

HKPredicateKeyPathEndDate

The key path for the sample’s end date.

HKPredicateKeyPathMetadata

The key path for accessing the object’s metadata dictionary inside a predicate format string.

HKPredicateKeyPathQuantity

The key path to the sample’s quantity.

HKPredicateKeyPathSource

The key path for accessing the object’s source inside a predicate format string.

HKPredicateKeyPathSourceRevision

The key path for accessing the object’s source revision inside a predicate format string.

HKPredicateKeyPathStartDate

The key path for the sample’s start date.

HKPredicateKeyPathUUID

The key path for accessing the object’s UUID inside a predicate format string.

HKPredicateKeyPathWorkout

The key path for accessing the object’s workout inside a predicate format string.

HKPredicateKeyPathWorkoutDuration

The key path for the workout’s duration.

HKPredicateKeyPathWorkoutTotalDistance

The key path for the workout’s total distance.

HKPredicateKeyPathWorkoutTotalEnergyBurned

The key path for the workout’s total energy burned.

HKPredicateKeyPathWorkoutType

The key path for the workout’s type.

HKSampleSortIdentifierEndDate

A constant for sorting samples based on their end date.

HKSampleSortIdentifierStartDate

A constant for sorting samples based on their start date.

HKUnitMolarMassBloodGlucose

The molecular mass of blood glucose, typically used to create mole units for blood glucose.

HKUserPreferencesDidChangeNotification

Notifies observers whenever the user changes his or her preferred units.

HKWorkoutSortIdentifierDuration

A constant for sorting workouts based on their duration.

HKWorkoutSortIdentifierTotalDistance

A constant for sorting workouts based on their total distance.

HKWorkoutSortIdentifierTotalEnergyBurned

A constant for sorting workouts based on the total energy burned.

HKQuantityTypeIdentifierDistanceSwimming

A quantity sample type that measures the distance the user has moved while swimming.

HKQuantityTypeIdentifierSwimmingStrokeCount

A quantity sample type that measures the number of strokes performed while swimming.

HKMetadataKeyAlpineSlopeGrade

A key that indicates the percent slope of a ski run.

HKMetadataKeyAverageSpeed

A key that indicates the average speed during a workout.

HKMetadataKeyElevationAscended

A key that indicates the cumulative elevation ascended during a workout.

HKMetadataKeyElevationDescended

A key that indicates the cumulative elevation descended during a workout.

HKMetadataKeyMaximumSpeed

A key that indicates the maximum speed during a workout.

HKWorkoutRouteTypeIdentifier

A series sample containing location data that defines the route the user took during a workout.