Class

HKHealthStore

The access point for all data managed by HealthKit.

Declaration

@interface HKHealthStore : NSObject

Overview

Use a HKHealthStore object to request permission to share or read HealthKit data. Once permission is granted, you can use the HealthKit store to save new samples to the store, or to manage the samples that your app has saved. Additionally, you can use the HealthKit store to start, stop, and manage queries.

For more information, see Setting Up HealthKit.

Topics

Accessing HealthKit

- authorizationStatusForType:

Returns the app’s authorization status for sharing the specified data type.

HKAuthorizationStatus

Constants indicating the authorization status for a particular data type.

- getRequestStatusForAuthorizationToShareTypes:readTypes:completion:

Indicates whether the system presents the user with a permission sheet if your app requests authorization for the provided types.

HKAuthorizationRequestStatus

Values that indicate whether your app needs to request authorization from the user.

+ isHealthDataAvailable

Returns a Boolean value that indicates whether HealthKit is available on this device.

- supportsHealthRecords

Returns a Boolean value that indicates whether the current device supports clinical records.

- requestAuthorizationToShareTypes:readTypes:completion:

Requests permission to save and read the specified data types.

- handleAuthorizationForExtensionWithCompletion:

Requests permission to save and read the data types specified by an extension.

Reading Characteristic Data

- biologicalSexWithError:

Reads the user’s biological sex from the HealthKit store.

- bloodTypeWithError:

Reads the user’s blood type from the HealthKit store.

- dateOfBirthWithError:

Reads the user’s date of birth from the HealthKit store.

Deprecated
- dateOfBirthComponentsWithError:

Reads the user’s date of birth from the HealthKit store.

- fitzpatrickSkinTypeWithError:

Reads the user’s Fitzpatrick Skin Type from the HealthKit store.

- wheelchairUseWithError:

Reads the user’s wheelchair use from the HealthKit store.

Working with HealthKit Objects

- deleteObject:withCompletion:

Deletes the specified object from the HealthKit store.

- deleteObjects:withCompletion:

Deletes the specified objects from the HealthKit store.

- deleteObjectsOfType:predicate:withCompletion:

Deletes objects saved by this application that match the provided type and predicate.

- earliestPermittedSampleDate

Returns the earliest date permitted for samples.

- saveObject:withCompletion:

Saves the provided object to the HealthKit store.

- saveObjects:withCompletion:

Saves an array of objects to the HealthKit store.

Managing Workouts

- addSamples:toWorkout:completion:

Associates the provided samples with the specified workout.

- splitTotalEnergy:startDate:endDate:resultsHandler:

Calculates the active and resting energy burned based on the total energy burned over the given duration.

Deprecated
- recoverActiveWorkoutSessionWithCompletion:

Recovers an active workout session.

Querying HealthKit Data

- executeQuery:

Starts executing the provided query.

- stopQuery:

Stops a long-running query.

Accessing the Preferred Units

- preferredUnitsForQuantityTypes:completion:

Returns the user’s preferred units for the given quantity types.

HKUserPreferencesDidChangeNotification

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

Managing Background Delivery

- enableBackgroundDeliveryForType:frequency:withCompletion:

Enables the background delivery of updates.

HKUpdateFrequency

Constants that determine how often the system will launch your app in response to changes to HealthKit data.

- disableBackgroundDeliveryForType:withCompletion:

Disables background deliveries of update notifications for the specified data type.

- disableAllBackgroundDeliveryWithCompletion:

Disables all background deliveries of update notifications.

Managing Workout Sessions

- startWatchAppWithWorkoutConfiguration:completion:

Launches or wakes the Watch app to create a new workout session.

- startWorkoutSession:

Starts a workout session for the current app.

Deprecated
- pauseWorkoutSession:

Pauses the provided workout session.

Deprecated
- resumeWorkoutSession:

Resumes the provided workout session.

Deprecated
- endWorkoutSession:

Ends a workout session for the current app.

Deprecated

Notifications

HKUserPreferencesDidChangeNotification

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

Relationships

Inherits From

See Also

Essentials

About the HealthKit Framework

Learn about the architecture and design of the HealthKit framework.

Setting Up HealthKit

Set up and configure your HealthKit store.

Protecting User Privacy

Respect and safeguard your user’s privacy.