HealthKit
JUSTIN BERGEN
FIVE3 APPS
HEALTHKIT
WHAT IS HEALTHKIT?
▸ Apple’s answer to the many disparate health and fitness
platforms.
▸ Stores an encrypted, centralized database of health information.
▸ Local device only.
▸ Does backup on encrypted backups only.
▸ Available on iOS and WatchOS, but not available on iPad.
▸ Health app allows the user to manage data and privacy.
HEALTH APP
DEMO
HEALTHKIT
HEALTHKIT DATA
▸ Characteristic data - date of birth, blood type, etc.
▸ Apps cannot change.
▸ Sample data - Most health data.
▸ Point in time sample.
▸ Source data - Information about the data source.
▸ Stored as part of a sample.
▸ Deleted object - Temp object to pass UUID for deleted item
HEALTHKIT
HKObject / HKSample
▸ Source revision - information about who wrote the sample.
▸ Device - (optional) information about the hardware the
sample came from.
▸ Type - the type of health data in the sample (steps,
calories, etc).
▸ Cannot create custom types
▸ Start/End date - timeframe for the sample.
TEXT
HKSample Subclasses
▸ Category - data is a finite set of categories (ie sleep
analysis - awake, inBed, asleep)
▸ Quantity - data that is stored as numeric value.
▸ Value uses specific unit type. For example,
HKUnit.kilocalorie()
▸ Correlation - food or blood pressure.
▸ Workouts - physical activity that can have multiple sample
types.
HEALTHKIT
APP TARGET CONFIGURATION
▸ Configure HealthKit entitlement.
▸ (optional) Remove required device capability.
▸ Set info.plist with Privacy - Health Share Usage Description
(read), and Privacy - Health Update Usage Description
(write)
▸ Make sure HealthKit.framework is linked
ACTIVITY CHECK
DEMO
HEALTHKIT
WATCH DIFFERENCES
▸ Less data available.
▸ earliestPermittedSampleDate()
▸ No background handlers.
▸ Use background app refresh instead and query data.
HEALTHKIT
PRO TIPS
▸ You are not told if the user denied access to your app.
▸ Completion handlers can be called from non-main threads.
▸ If your app needs to run on iPad (not just Universal), then
remove HealthKit from required device capabilities
QUESTIONS
HEALTHKIT
RESOURCES
▸ HealthKit Framework Reference

https://developer.apple.com/reference/healthkit
▸ Activity Check Demo App Source

https://github.com/Five3Apps/HealthKitDemo
▸ Contact Me

http://five3apps.com/

justin@five3apps.com

Apple Health Kit

  • 1.
  • 2.
    HEALTHKIT WHAT IS HEALTHKIT? ▸Apple’s answer to the many disparate health and fitness platforms. ▸ Stores an encrypted, centralized database of health information. ▸ Local device only. ▸ Does backup on encrypted backups only. ▸ Available on iOS and WatchOS, but not available on iPad. ▸ Health app allows the user to manage data and privacy.
  • 3.
  • 4.
    HEALTHKIT HEALTHKIT DATA ▸ Characteristicdata - date of birth, blood type, etc. ▸ Apps cannot change. ▸ Sample data - Most health data. ▸ Point in time sample. ▸ Source data - Information about the data source. ▸ Stored as part of a sample. ▸ Deleted object - Temp object to pass UUID for deleted item
  • 5.
    HEALTHKIT HKObject / HKSample ▸Source revision - information about who wrote the sample. ▸ Device - (optional) information about the hardware the sample came from. ▸ Type - the type of health data in the sample (steps, calories, etc). ▸ Cannot create custom types ▸ Start/End date - timeframe for the sample.
  • 6.
    TEXT HKSample Subclasses ▸ Category- data is a finite set of categories (ie sleep analysis - awake, inBed, asleep) ▸ Quantity - data that is stored as numeric value. ▸ Value uses specific unit type. For example, HKUnit.kilocalorie() ▸ Correlation - food or blood pressure. ▸ Workouts - physical activity that can have multiple sample types.
  • 7.
    HEALTHKIT APP TARGET CONFIGURATION ▸Configure HealthKit entitlement. ▸ (optional) Remove required device capability. ▸ Set info.plist with Privacy - Health Share Usage Description (read), and Privacy - Health Update Usage Description (write) ▸ Make sure HealthKit.framework is linked
  • 8.
  • 9.
    HEALTHKIT WATCH DIFFERENCES ▸ Lessdata available. ▸ earliestPermittedSampleDate() ▸ No background handlers. ▸ Use background app refresh instead and query data.
  • 10.
    HEALTHKIT PRO TIPS ▸ Youare not told if the user denied access to your app. ▸ Completion handlers can be called from non-main threads. ▸ If your app needs to run on iPad (not just Universal), then remove HealthKit from required device capabilities
  • 11.
  • 12.
    HEALTHKIT RESOURCES ▸ HealthKit FrameworkReference
 https://developer.apple.com/reference/healthkit ▸ Activity Check Demo App Source
 https://github.com/Five3Apps/HealthKitDemo ▸ Contact Me
 http://five3apps.com/
 justin@five3apps.com