For a quick demo app and easy code samples, check out the plugin page at the Verified Plugins Marketplace: http://plugins.telerik.com/plugin/healthkit |
See the example for how to use these functions.
available
: check if HealthKit is supported (iOS8+, not on iPad)checkAuthStatus
: pass in a type and get back on of undetermined | denied | authorizedrequestAuthorization
: ask some or all permissions up frontreadDateOfBirth
: formatted as yyyy-MM-ddreadGender
: output = male|female|other|unknownreadBloodType
: output = A+|A-|B+|B-|AB+|AB-|O+|O-|unknownreadFitzpatrickSkinType
: output = I|II|III|IV|V|VI|unknownreadWeight
: pass in unit (g=gram, kg=kilogram, oz=ounce, lb=pound, st=stone)saveWeight
: pass in unit (g=gram, kg=kilogram, oz=ounce, lb=pound, st=stone) and amountreadHeight
: pass in unit (mm=millimeter, cm=centimeter, m=meter, in=inch, ft=foot)saveHeight
: pass in unit (mm=millimeter, cm=centimeter, m=meter, in=inch, ft=foot) and amountsaveWorkout
findWorkouts
: no params yet, so this will return all workouts ever of any typequerySampleType
querySampleTypeAggregated
sumQuantityType
monitorSampleType
saveQuantitySample
saveCorrelation
queryCorrelationType
deleteSamples
-
The official Apple documentation for HealthKit can be found here.
-
For functions that require the
unit
attribute, you can find the comprehensive list of possible units from the Apple Developers documentation.
- Make sure your app id has the 'HealthKit' entitlement when this plugin is installed. This is added automatically to your app if you use cordova-ios 4.3.0 or higher.
- Also, make sure your app and AppStore description complies with these Apple review guidelines: https://developer.apple.com/app-store/review/guidelines/#healthkit
Using the Cordova CLI?
cordova plugin add com.telerik.plugins.healthkit --variable HEALTH_READ_PERMISSION='App needs read access' --variable HEALTH_WRITE_PERMISSION='App needs write access'
HEALTH_READ_PERMISSION
and HEALTH_WRITE_PERMISSION
are shown when your app asks for access to data in HealthKit.
Using PhoneGap Build?
<plugin name="com.telerik.plugins.healthkit" source="npm" />
<!-- Read access -->
<config-file platform="ios" parent="NSHealthShareUsageDescription">
<string>App needs read access</string>
</config-file>
<!-- Write access -->
<config-file platform="ios" parent="NSHealthUpdateUsageDescription">
<string>App needs write access</string>
</config-file>