Understanding HealthKit

HealthKit is a framework that allows developers to interact with a user's health data. This data includes information like a user's weight, BMI, blood type, biological sex, skin type, date of birth, whether they use a wheelchair, and much more. In addition to these metrics, HealthKit also provides access to activity data, such as workouts or the amount of steps the user has walked on a given day.

HealthKit is available on the iPhone and Apple Watch only. The iPad does not have support for HealthKit, so you must take special precautions to determine whether HealthKit is available, by calling isHealthDataAvailable() on the HKHealthStore class.

Because health data is considered private and thus very sensitive, apps that want access to health data have to specify their reasons for wanting to read and/or write data to HealthKit in the Info.plist, under the following keys:

  • Privacy: Health Share Usage Description (NSHealthShareUsageDescription) for reading data from the HealthKit store
  • Privacy: Health Update Usage Description (NSHealthUpdateUsageDescription) for writing data to the HealthKit store
  • Privacy: Health Records Usage Description (NSHealthClinicalHealthRecordsShareUsageDescription) for reading record data from the HealthKit store

In addition to adding the appropriate Info.plist entries, you must also enable the HealthKit capability in your app's Capabilities tab. This will configure your app with the required entitlements for accessing the HealthKit store. When you enable the HealthKit capability, you have the option to enable access to health records. Health records are specific records that contain clinical data.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset