What Is Healthkit
In 2014, Apple introduced HealthKit alongside iOS 8. HealthKit is Apple's solution for storing, managing, and sharing health data. HealthKit enables developers to read and write health data to a database managed by the operating system.
It goes without saying that this opens up a wide range of possibilities for developers. Thousands of applications already integrate with HealthKit. In this article, I would like to take a closer look at what HealthKit is and what developers can, and cannot, use it for.
What Is It?
HealthKit is more than a container for storing and sharing health data. For the user, it is a convenient way to aggregate data related to health and fitness. For developers, HealthKit is a platform that makes collecting and managing health data easy, convenient, and powerful.
A key feature of HealthKit is the ability to share health data with other applications. Some applications collect data while others aggregate data. HealthKit is a great fit for both types of applications.
Any application that integrates with HealthKit can insert data into and read data from HealthKit's database. That said, the user needs to grant an application permissions for reading and writing data to HealthKit's database. Health data is often sensitive data and that brings us to privacy.
Apple continuous to emphasize how much it cares about the privacy of its customers and HealthKit underlines this commitment. Applications integrating with HealthKit need to request the user's permission for reading and/or writing the data managed by HealthKit.
The user decides which data a particular application can and cannot access. The HealthKit framework is very strict with regards to permissions. Let me give you an example. An application can ask HealthKit whether it can write data of a particular type, but it cannot ask whether it is allowed to read data of a particular type.
While this may surprise you, whether or not an application is permitted to read health data of a particular type is in itself sensitive data. The fact that someone does not allow your application to read health data of a particular type may hint at a condition related to that type of data. That is how committed Apple is with respect to your privacy.
Depending on the type of application you are creating, collecting, organizing, and maintaining data can be a complex undertaking. HealthKit neatly abstracts this away from the developer. Even though the HealthKit API can be pretty intimidating at first, it exposes a powerful API for reading, writing, and monitoring data.
The data managed by HealthKit is only stored locally and Apple emphasizes that an application should not store health data in iCloud. The App Store Review Guidelines explicitly state that applications that store health information obtained through HealthKit in iCloud will be rejected.
HealthKit is not supported by iPad. While I understand that iPad applications are not the most practical running companions, it is odd that Apple hasn't added HealthKit support for the iPad device family. Because HealthKit data is only stored locally, I assume Apple limits support for HealthKit to the customer's most personal device, their phone.
More To Come
Apple emphasized its commitment to HealthKit by releasing a range of improvements and optimizations. It is clear the company is listening to the feedback of the developer community.
While Apple encourages developers to integrate HealthKit into their applications, the company aggregates and presents the user's health data in Health for iOS.
Health provides the user with a convenient way to input health data, see an overview of what data is managed by HealthKit, and share it with medical practitioners.
Is HealthKit for You?
You may be wondering whether HealthKit is useful for your application. If your application has anything to do with health or fitness, it may be interesting to add support for HealthKit. You will be surprised by how easy it is to add support for HealthKit. The users of your application will thank you for it.
HealthKit also supports watchOS and this opens up even more possibilities for integrating with HealthKit. Health and fitness are hot topics and it looks like Apple is committed to getting a foothold in a market that continuous to grow.
In the rest of this series, we explore the HealthKit framework. In the next tutorial, I show you how to set up a project for HealthKit and how to request the user's permission for interacting with the data managed by HealthKit.
Questions? Leave them in the comments below or reach out to me on Twitter.