Use This Library to Integrate Apple HealthKit with React Native

1 in 5 adults in the U.S. use health apps or wearable trackers, or both.


Based on that statistic, we can assume a few things about society today:

  1. People care about their health, and they’re taking advantage of opportunities to improve it.
  2. Health tech is becoming more advanced, personalized, and accessible than ever before.
  3. Since there are over 100 million iPhone users in the U.S. alone, we can assume a considerable number of people also use Apple Health, the iPhone’s built-in health app, because the most popular wearables link to the app.

Knowing that millions of people's data are stored and updated in Apple Health every day, many developers and startup founders will want to leverage Apple Health to bring their own apps and ideas to life. Including us at AE Studio.

Last year, we took on a fun new project: building an iOS app for a startup called Point that would generate specific, personalized fitness recommendations and insights for users based on metrics from wearable devices and health/fitness apps.

We figured out that the best way to build the app was to utilize Apple Health’s ability to collect metrics like step count, heart rate, and calories burned, among others, from many different wearable devices and apps. This way, we could use Apple Health as a warehouse for all of the data instead of integrating with every wearable device and app and collecting specific metrics from each of them. Our plan was to read all of the data from Apple Health and write it into a custom-built recommendations engine that would crank out advice for the user.

Photo from wareable.com

It sounds like a good idea—and it was 😉—but the process wasn’t as straightforward as we hoped. Apple uses its own programming language, Swift (or previously Objective-C). Since we were using React Native to build the app, we needed to read and write the information in JavaScript.

So we searched for a tool that would help us do that. Unfortunately, the search was kind of like the toilet paper shortage of 2020. We could only find one thing—one last roll of toilet paper on the shelf—the React Native Apple Healthkit, a React Native bridge model for interacting with Apple Healthkit data.

This library was a good start, but it didn’t have everything we needed, and the project had been abandoned. Another company, NutriSense, created a fork with their own features, mainly related to measuring glucose levels, but it still wasn’t comprehensive enough.

The owner of the original React Native Apple Healthkit project was looking for someone to take over, so we ran with it and created React Native Health, merging the two repositories and getting everything up to date.

Download it from npm here and view all of the documentation here.

We added a bunch of new features that we needed for the project we were working on, along with some we thought would be useful for other developers in the future. React Native Health now has background observers for each metric, support for new iOS 14 activities/workouts, a Vo2 Max collection, a mindful minutes collection, and more.

The project started in the open-source community. We’re keeping it there in hopes that other people will use it, contribute to it, and help us improve it—especially as wearable devices and health/fitness apps continue to evolve and add more functionalities.

There’s a lot of potential here already. For instance, the Apple Watch Series 6 can measure blood oxygen levels, so we added that to the library. We figured that’d be critical data to access, especially since many COVID-19 patients have low oxygen levels in their blood. Info like this could help a team of developers create some sort of COVID-19 detector app or something of that nature. One company is already planning to use the library to detect and monitor diabetes in patients.

Right now, we’re in the process of migrating the codebase from Objective-C to Swift because Objective-C is basically dead. Interested in helping out or have any suggestions? View the issues tracker to find the features and bugs to work on, and check out our contributing documentation for some tips on getting started.

No one works with an agency just because they have a clever blog. To work with my colleagues, who spend their days developing software that turns your MVP into an IPO, rather than writing blog posts, click here (Then you can spend your time reading our content from your yacht / pied-a-terre). If you can’t afford to build an app, you can always learn how to succeed in tech by reading other essays.