Metadata Keys

Constants used to add metadata to objects stored in HealthKit.

Overview

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.

Topics

General Keys

HKMetadataKeyExternalUUID

A unique identifier for an HKObject that is set by its source.

HKMetadataKeyTimeZone

The user’s time zone when the HealthKit object was created.

HKMetadataKeyWasUserEntered

A key that indicates whether the sample was entered by the user.

Device Information Keys

HKMetadataKeyDeviceSerialNumber

The key for the serial number of the device that generated the data.

HKMetadataKeyUDIDeviceIdentifier

The device identifier portion of a device’s UDI (unique device identifier).

HKMetadataKeyUDIProductionIdentifier

The production identifier portion of a device’s UDI (unique device identifier).

HKMetadataKeyDigitalSignature

A digital signature that can be used to validate the origin of the HealthKit object.

HKMetadataKeyDeviceName

The name of the device that took this reading.

HKMetadataKeyDeviceManufacturerName

The name of the manufacturer of the device that took this reading.

Sync Keys

HKMetadataKeySyncIdentifier

A unique string that identifies a piece of data so it can be updated and synced.

HKMetadataKeySyncVersion

The version number for a piece of data, used when updating or syncing.

Lab Keys

HKMetadataKeyWasTakenInLab

A key that indicates whether the sample was taken in a lab.

HKMetadataKeyReferenceRangeLowerLimit

A key that indicates the lower limit of the reference range for a lab result.

HKMetadataKeyReferenceRangeUpperLimit

A key that indicates the upper limit of the reference range for a lab result.

Weather Keys

HKMetadataKeyWeatherCondition

A key that represents the weather condition during the sample.

HKMetadataKeyWeatherTemperature

A key that represents the weather temperature during the sample.

HKMetadataKeyWeatherHumidity

A key that represents the weather humidity during the sample.

Workout Keys

Workout Metadata Keys

Constants that can be used to add metadata to workouts.

Nutrition Keys

HKMetadataKeyFoodType

The type of food that the HealthKit object represents.

Vitals Sensors Keys

HKMetadataKeyBodyTemperatureSensorLocation

The location where a particular body temperature reading was taken.

HKMetadataKeyHeartRateSensorLocation

The location where a particular heart rate reading was taken.

HKMetadataKeyHeartRateMotionContext

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

HKMetadataKeyVO2MaxTestType

The method used to calculate the user’s VO2 max rate.

Audio Event Keys

HKMetadataKeyAudioExposureLevel

The audio level associated with an audio event.

Blood Glucose Keys

HKMetadataKeyBloodGlucoseMealTime

A key that indicates the relative timing of a blood glucose reading to a meal.

HKMetadataKeyInsulinDeliveryReason

The medical reason for administering insulin.

Reproductive Health Keys

HKMetadataKeyMenstrualCycleStart

A key that indicates whether the sample represents the start of a menstrual cycle. This metadata key is required for HKCategoryTypeIdentifierMenstrualFlow category samples.

HKMetadataKeySexualActivityProtectionUsed

A key that indicates whether protection was used during sexual activity. This metadata key can be used with HKCategoryTypeIdentifierSexualActivity category samples.

See Also

First Steps

Saving Data to HealthKit

Create and share HealthKit samples.

HKCumulativeQuantitySample

A sample that represents a cumulative quantity.

HKDiscreteQuantitySample

A sample that represents a discrete quantity.

HKQuantitySample

A sample that represents a quantity, including the value and the units.

HKCategorySample

A sample whose values are selected from a short list of possible values.

HKCorrelation

A sample that groups multiple related samples into a single entry.

Units and Quantities

Objects used to specify a quantity for a given unit (for example, 175 lbs), and to convert between units (79.4 kg).