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

let HKMetadataKeyExternalUUID: String

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

let HKMetadataKeyTimeZone: String

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

let HKMetadataKeyWasUserEntered: String

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

Device Information Keys

let HKMetadataKeyDeviceSerialNumber: String

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

let HKMetadataKeyUDIDeviceIdentifier: String

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

let HKMetadataKeyUDIProductionIdentifier: String

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

let HKMetadataKeyDigitalSignature: String

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

let HKMetadataKeyDeviceName: String

The name of the device that took this reading.

let HKMetadataKeyDeviceManufacturerName: String

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

Sync Keys

let HKMetadataKeySyncIdentifier: String

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

let HKMetadataKeySyncVersion: String

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

Lab Keys

let HKMetadataKeyWasTakenInLab: String

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

let HKMetadataKeyReferenceRangeLowerLimit: String

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

let HKMetadataKeyReferenceRangeUpperLimit: String

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

Weather Keys

let HKMetadataKeyWeatherCondition: String

A key that represents the weather condition during the sample.

let HKMetadataKeyWeatherTemperature: String

A key that represents the weather temperature during the sample.

let HKMetadataKeyWeatherHumidity: String

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

let HKMetadataKeyFoodType: String

The type of food that the HealthKit object represents.

Vitals Sensors Keys

let HKMetadataKeyBodyTemperatureSensorLocation: String

The location where a particular body temperature reading was taken.

let HKMetadataKeyHeartRateSensorLocation: String

The location where a particular heart rate reading was taken.

let HKMetadataKeyHeartRateMotionContext: String

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

let HKMetadataKeyVO2MaxTestType: String

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

Blood Glucose Keys

let HKMetadataKeyBloodGlucoseMealTime: String

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

let HKMetadataKeyInsulinDeliveryReason: String

The medical reason for administering insulin.

Reproductive Health Keys

let HKMetadataKeyMenstrualCycleStart: String

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

let HKMetadataKeySexualActivityProtectionUsed: String

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

See Also

First Steps

Saving Data to HealthKit

Create and share HealthKit samples.

class HKQuantitySample

A sample that represents the quantity (both the value and units) of a single measurement.

class HKCategorySample

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

class 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).