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.

enum HKBodyTemperatureSensorLocation

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

enum HKHeartRateSensorLocation

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

enum 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 food.

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.

enum HKWorkoutActivityType

The type of activity performed during a workout.

enum HKWorkoutSessionState

A workout session’s state.

enum 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.

enum HKError.Code

Error codes that may be returned when calling HealthKit methods.

enum HKUpdateFrequency

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

enum HKAuthorizationStatus

Constants indicating the authorization status for a particular data type.

enum 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.

enum HKCategoryValueSleepAnalysis

Categories used when analyzing sleep samples.

enum HKCategoryValueAppleStandHour

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

enum HKCategoryValueCervicalMucusQuality

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

enum HKCategoryValueOvulationTestResult

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

enum HKCategoryValueMenstrualFlow

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

enum HKCategoryValue

Miscellaneous category values.

enum 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.

enum HKBloodType

Constants indicating the user’s blood type.

enum HKWheelchairUse

Constants indicating the user’s wheelchair use.

Constants

var HKAnchoredObjectQueryNoAnchor: Int32

Use this constant to define an anchored object query that returns all of the matching samples currently in the HealthKit store.

let HKDetailedCDAValidationErrorKey: String

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

let HKDevicePropertyKeyFirmwareVersion: String

The device’s firmware version.

let HKDevicePropertyKeyHardwareVersion: String

The device’s hardware version.

let HKDevicePropertyKeyLocalIdentifier: String

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

let HKDevicePropertyKeySoftwareVersion: String

The device’s software version.

let HKDevicePropertyKeyUDIDeviceIdentifier: String

The device’s UDI Device Identifier.

let HKObjectQueryNoLimit: Int

The query returns all the samples in the HealthKit store that match the given sample type and predicate.

let HKPredicateKeyPathCDAAuthorName: String

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

let HKPredicateKeyPathCDACustodianName: String

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

let HKPredicateKeyPathCDAPatientName: String

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

let HKPredicateKeyPathCDATitle: String

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

let HKPredicateKeyPathCategoryValue: String

The key path for the category sample’s value.

let HKPredicateKeyPathCorrelation: String

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

let HKPredicateKeyPathDateComponents: String

A key path for the summary’s date components.

let HKPredicateKeyPathDevice: String

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

let HKPredicateKeyPathEndDate: String

The key path for the sample’s end date.

let HKPredicateKeyPathMetadata: String

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

let HKPredicateKeyPathQuantity: String

The key path to the sample’s quantity.

let HKPredicateKeyPathSource: String

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

let HKPredicateKeyPathSourceRevision: String

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

let HKPredicateKeyPathStartDate: String

The key path for the sample’s start date.

let HKPredicateKeyPathUUID: String

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

let HKPredicateKeyPathWorkout: String

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

let HKPredicateKeyPathWorkoutDuration: String

The key path for the workout’s duration.

let HKPredicateKeyPathWorkoutTotalDistance: String

The key path for the workout’s total distance.

let HKPredicateKeyPathWorkoutTotalEnergyBurned: String

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

let HKPredicateKeyPathWorkoutType: String

The key path for the workout’s type.

let HKSampleSortIdentifierEndDate: String

A constant for sorting samples based on their end date.

let HKSampleSortIdentifierStartDate: String

A constant for sorting samples based on their start date.

var HKUnitMolarMassBloodGlucose: Double

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

let HKWorkoutSortIdentifierDuration: String

A constant for sorting workouts based on their duration.

let HKWorkoutSortIdentifierTotalDistance: String

A constant for sorting workouts based on their total distance.

let HKWorkoutSortIdentifierTotalEnergyBurned: String

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

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software