Need help upgrading to Ionic Framework 4.0? Get assistance with our Enterprise Migration Services EXPLORE NOW

Health Kit

Improve this doc

The HealthKit plugin allows you to read data from and write data to the iOS 8+ HealthKit framework. Any data saved shows up in the iOS Health app and is available for other iOS apps.

Repo: https://github.com/Telerik-Verified-Plugins/HealthKit

Installation

  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add com.telerik.plugins.healthkit
    $ npm install --save @ionic-native/health-kit@4
    
  2. Add this plugin to your app's module

Supported platforms

Usage

import { HealthKit } from '@ionic-native/health-kit';


constructor(private healthKit: HealthKit) { }

...

Instance Members

available()

Check if HealthKit is supported (iOS8+, not on iPad)

Returns: Promise<any>

checkAuthStatus(options)

Pass in a type and get back on of undetermined | denied | authorized

Param Type Details
options HealthKitOptions

Returns: Promise<any>

requestAuthorization(options)

Ask some or all permissions up front

Param Type Details
options HealthKitOptions

Returns: Promise<any>

readDateOfBirth()

Formatted as yyyy-MM-dd

Returns: Promise<any>

readGender()

Output = male female other unknown

Returns: Promise<any>

readBloodType()

Output = A+ A- B+ B- AB+ AB- O+ O- unknown

Returns: Promise<any>

readFitzpatrickSkinType()

Output = I II III IV V VI unknown

Returns: Promise<any>

saveWeight(options)

Pass in unit (g=gram, kg=kilogram, oz=ounce, lb=pound, st=stone) and amount

Param Type Details
options HealthKitOptions

Returns: Promise<any>

readWeight(options)

Pass in unit (g=gram, kg=kilogram, oz=ounce, lb=pound, st=stone)

Param Type Details
options HealthKitOptions

Returns: Promise<any>

saveHeight(options)

Pass in unit (mm=millimeter, cm=centimeter, m=meter, in=inch, ft=foot) and amount

Param Type Details
options HealthKitOptions

Returns: Promise<any>

readHeight(options)

Pass in unit (mm=millimeter, cm=centimeter, m=meter, in=inch, ft=foot)

Param Type Details
options HealthKitOptions

Returns: Promise<any>

findWorkouts()

no params yet, so this will return all workouts ever of any type

Returns: Promise<any>

saveWorkout(options)

Param Type Details
options HealthKitOptions

Returns: Promise<any>

querySampleType(options)

Param Type Details
options HealthKitOptions

Returns: Promise<any>

querySampleTypeAggregated(options)

Param Type Details
options HealthKitOptions

Returns: Promise<any>

deleteSamples(options)

Param Type Details
options HealthKitOptions

Returns: Promise<any>

monitorSampleType(options)

Param Type Details
options HealthKitOptions

Returns: Promise<any>

sumQuantityType(options)

Param Type Details
options HealthKitOptions

Returns: Promise<any>

saveQuantitySample(options)

Param Type Details
options HealthKitOptions

Returns: Promise<any>

saveCorrelation(options)

Param Type Details
options HealthKitOptions

Returns: Promise<any>

queryCorrelationType(options)

Param Type Details
options HealthKitOptions

Returns: Promise<any>

HealthKitOptions

Param Type Details
activityType string

HKWorkoutActivityType constant Read more here: https://developer.apple.com/library/ios/documentation/HealthKit/Reference/HKWorkout_Class/#//apple_ref/c/tdef/HKWorkoutActivityType

(optional)
aggregation string

'hour', 'week', 'year' or 'day', default 'day'

(optional)
amount number (optional)
ascending boolean

specifies if the data returned by querySampleType() should be sorted by end date in ascending order, default is false

(optional)
correlationType string (optional)
date any (optional)
distance number (optional)
distanceUnit string

probably useful with the former param

(optional)
duration number

in seconds, optional, use either this or endDate

(optional)
endDate any (optional)
energy number (optional)
energyUnit string

J|cal|kcal

(optional)
extraData any (optional)
limit number

limits the maximum number of records returned by querySampleType()

(optional)
metadata any (optional)
quantityType string (optional)
type string (optional)
readTypes any (optional)
requestWritePermission boolean (optional)
samples any (optional)
sampleType string (optional)
startDate any (optional)
unit string

m|cm|mm|in|ft

(optional)
requestReadPermission boolean (optional)
writeTypes any (optional)

API

Native

General