Apple’s API, HealthKit was introduced with iOS 8.0 in Worldwide Developers Conference 2014. It lets users build a biological profile and store data related to workouts by acting as a central repository for health-related data. The app, Health is available from iPhone 4s onwards and iPod Touch (5th generation onwards). Also, for the app to function well, the iCloud-enabled device is required.

Why HealthKit is needed and how it helps?

It is unquestionable that present lifestyles are affecting the health of many and it’s become a necessity to stay fit, healthy and wealthy. Thus, the technology world is coming up with new innovations in digital health domain and HealthKit software development every day. Apple HealthKit developers are leveraging the best out of them while walking hand-in-hand by adopting innovations like Apple’s HealthKit and Health. Let’s Nurture, an ISO 9001:2015 certified mobile app development company based in Ahmedabad, India believes that Healthcare app development has opened up new possibilities in the domain of digital health.

You may like to read: 5 Fantastic IoT based Solutions in Healthcare Industry

With HealthKit, you get pre-defined HKHealthStore’s methods to read and write data into the central repository and manage the data as needed. HealthKit enables users to store health-related data about a number of functions from body steps count to dietary Vitamin in one’s body. The basic data like height, weight, blood group and gender of a person can be fetched from his or her profile. The Health app available on the iPhones can be used to import data from Apple Watch Series 4+ and various iOS supported wearable devices. That data is analyzed further to help users maintain a healthy and fit life.

Apple extended in the domain of digital healthcare by introducing many health tracking features with Apple Watch Series 4. Apple watch can be used to track your health and collect data about the distance you cover, steps you covered and much more. With iOS 11.3 onwards this data can also be imported into the Health app from various resources like an Apple Watch, external app or anybody else’s device. The users can thus collect health-related data from various places and get an accurate report about their health.

Apple Watch Series 4 onwards, the Apple Watch checks your heart rate and alarms you about any irregularities between your heartbeats. You can also generate the ECG reports from Health app after the data is being imported to the app from the Watch.

 

Also, Medical Id can now be set up in the Health app. In case of emergency, his Medical Id can be used to get your important medical data from iPhone’s lock screen without the passcode. This information can serve well in case one meets with an unforeseen situation and needs immediate treatment.

How to work with HealthKit?

Checking HealthKit availability
To use the HealthKit APIs, iOS users need Health app installed on their device. Health is available on iOS devices with iOS 8.0 or higher. In the Health app, you must first complete your profile by adding the asked information and now you’re good to use the app and HealthKit.

Apple HealthKit Latest Technical Features

Here is a Glimpse of functionality our iOS HealthKit app developers have worked with HealthKit API Integration and following HKQuantityTypeIdentifier :

  • RestingHeartRate : Reading the lowest heart rate, when the body is least active and resting.
  • WalkingHeartRateAverage : Fetching the average heart rate while walking.
  • HeartRateVariabilitySDNN : Measuring the standard deviation of heartbeat intervals.
  • InsulinDelivery : The amount of insulin delivered can be measured.
  • DistanceDownhillSnowSports : the distance covered by the user while skiing or snowboarding.
  • Vo2Max : Measuring the maximal oxygen during exercise.

Assigning Team

In order to start the development of any HealthKit app to work with HKQuantityTypeIdentifier like mentioned above, our iOS developers have an active Apple developer account from where they first assign a team (code signing) to access this special framework.

Entitlements

Next, we need to enable the project (our app) to use the HealthKit. For that, go to TARGET -> Capabilities and turn on the HealthKit switch.

Permissions

In order to access the data after HealthKit API Integration, we first need to mention the reason behind asking for the data. Apple gives us a way to do that.

Open the info.plist in your project, and add the key Privacy – Health Share Usage Description for reading the data from the repository and Privacy – Health Update Usage Description for writing the data into the repository.

Singleton Pattern

iOS developers here at Let’s Nurture use a base class to execute the basics of HealthKit to avoid allocating those every time Healthkit is to be used in the app.

HealthKit Authorization

For requesting authorization for HealthKit, authorizeHealthKit (completion:) method is to be used. The method accepts no parameters and has a completion handler with returns a boolean value upon the successful completion or failure of the method along with the optional error.

There are four necessary elements required to complete the method:

  1. Check to know, if the device has HealthKit available on it. If not, return with failure and error.
  2. Preparing the types of Health data the project will read and write to HealthKit
  3. Arranging the data into the types of data to be read and written.
  4. Lastly, request for the authorization and complete with success if it is successful.

When you run the app now, you’ll see an authorization screen pop up. Give access and turn on all the switches to access them all.

Working with HealthKit

Fetching the data from HealthKit: Querying Sample in the base class
To get the data, our iOS developers need to mention the type of sample you need to query.

To filter and sort the data iOS app developers can pass additional parameters: NSPredicate and NSSortDescriptor.

Once the parameters and query are set up, all you need to do is call the HKHealthStore’s executeQuery method.

A common method for Writing Data into the HealthKit in the base class

You have to set up a type of sample the same as done in the query method. Then call HKHealthStore’s save method and successfully save the data into the repository, i.e., HealthKit.

Read Data from HeakthKit from anywhere in the iOS app

To read the data for any type of sample from HealthKit, iOS developer can now call the read method from the base class.

 

and Write Data into HeakthKit from anywhere in the iOS app

To write the data for any type of sample into the HealthKit, iOS developer can now call the read method from the base class.

To explore the whole project and application, you can check the project here.

How Apple Health has been delivering Digital Health Solutions with other technologies?

Apple Health app, along with the Apple Watch and iOS wearable devices like K’WATCH Glucose serves as a great platform to track various data from glucose levels to distinct vitamin levels in a person’s blood. These data are also with precision and are a great support for staying a healthy.

Many renowned apps like Strava provide complete support to configure Apple Watch to measure health-related data like steps count. Strava is designed in a very sport-specific way, integrated with Apple Watch and re-engineered since Watch Series 2.

How Let’s Nurture helps in delivering Digital Health Solutions with HealthKit?

Let’s Nurture, a leading IT company known for custom iOS mobile app development in India has got the expertise in providing many solutions for healthcare app development, using frameworks like HealthKit, CoreData, CorePlot and CoreGraphs which helps storing, fetching, writing and analyzing health-related data into iOS applications. We at Let’s Nurture can provide solutions for people, interested in digital health solutions and much more based on applications for healthcare using wearables IoT and HealthKit.

This is one of our contribution to the digital healthcare solutions. This health based app, MedCheck is used for tracking heart rate, measuring blood pressure, oxygen and glucose levels and calculating BMI of a person. For recording the data we use IoT-enabled medical devices and analyze it through AI-enabled algorithms to offer unique subscription service to help corporates measure health and wellness metrics of their workforce through provision of easy-to-use, portable and wireless-enabled health check-up kiosk at their premises. Some data like step counts are imported through HealthKit API integration into our app to enhance the services offered.

You can also hire dedicated iOS developers at affordable prices with flexible engagement models as per your business needs.

If you want to know more about digital Healthcare Solutions with HealthKit and iOS fitness app development or want to implement this technology in your existing mobile app, get a free consultation from our iOS experts at Let’s Nurture.

Want to work with us? We're hiring!