Month: June 2014

iOS 8 API. A look at Home Kit

iOS 8 API. A look at Home Kit


Home Kit is another exciting new framework being release with iOS 8 in the Fall of 2014. If you’d like to read the overview from Apple, they’ve posted an article explaining the high level features. Home Kit is similar to Health Kit in that the data is stored in a central database for other apps to interact with. I’ll be getting into some of the specifics of the API and an overview of the new Home Kit Accessory Simulator.

The main idea of Home Kit is to communicate with physical devices through an iOS device (iPod, iPhone, iPad). Siri is integrated into Home Kit so you can control physical devices through voice commands. It will be interesting to see all of the devices that will be integrated with Home Kit in the coming years. This will be a huge selling point for Apple going forward as more and more manufacturers come on board.

Here’s how the object hierarchy works: Home (HMHome) -> Rooms (HMRoom) -> Accessories (HMAccessory) -> Services (HMService). Rooms can also be grouped into zones (HMZone).

  • Home:
    A home is meant to be a single physical location. A user may have multiple homes set up on their device.
  • Rooms:
    A room is meant to be used as a grouping for a devices (accessories). An example is if you wanted all of your lights in your family room to be turned on or off at once, you could tell Siri “Turn on the lights in the family room”.
  • Accessories:
    Accessories are part of a home, but can also be assigned to a room in that home. An accessory is a physical device that is specially built to communicate with the Home Kit API. Your oven may be built to interact with the Home Kit API, so you could say “Preheat the oven to 350” (Which would be wicked cool).
  • Services:
    Services are different functions of an accessory. So an oven would have multiple features like heating, setting a timer, and turning the oven light on/off.
  • Zones:
    Rooms can be grouped into zones, so you could group all of your rooms in the basement into the basement zone. At that point you can command a function for all accessories in a collection of rooms such as “Turn off the lights in the basement”.

Let’s take a look at the Home Kit Accessory Simulator. In Beta 1 of XCode 6 you can add accessories for the HMAccessoryBrowser to find. I assume updates in the future will also allow developers to add services to interact with as well.

let browser = HMAccessoryBrowser()

Screenshot 2014-06-16 13.54.04

Once your code identifies accessories in the home, you can then choose to add them to a room.

When Beta 2 is released I’ll expand on this article and show some concrete code examples.

After reviewing the Home Kit API, this could potentially be a really big deal for Apple. This will help take home automation to the next level making it mainstream in the next 3-5 years.

iOS 8 API. A look at Health Kit

iOS 8 API. A look at Health Kit

Health Kit is introduced with iOS 8 as part of the new HealthKit.framework. I created a new project to play around with the new functionality available to developers. The most interesting class to developers will be the HKHealthStore class which will allow the sharing of the user’s health data to other apps. The user chooses which data will be accessible to other applications.

The first thing you check for is the bool property isHealthDataAvailable. That will check if Health Kit is available on the device.

let dataAvailable = HKHealthStore.isHealthDataAvailable()

Health Kit allows the developer to write data to the Health Kit data store. Any data written by the app can be accessed for read and write access whenever it’s needed.

Before an app can access data, it must request access. 3 different types of access include BiologicalSex, BloodType and DateOfBirth:


This is a simple introduction to the API as it has much more functionality for developers including the ability to write queries against the data.

Health Kit is sure to be a hit with iOS users as health related apps are already very popular in the app store. Being able to centralize a users data will add a lot of cohesiveness among apps which will bring a better user experience to iOS users going forward.