Skip to content

Commit

Permalink
#72 Add support for HKCharacteristic (Fitzgerald skintype)
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Aug 11, 2016
1 parent 4151bbf commit 5eb7bdb
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 114 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* `readDateOfBirth`: formatted as yyyy-MM-dd
* `readGender`: output = male|female|unknown
* `readBloodType`: output = A+|A-|B+|B-|AB+|AB-|O+|O-|unknown
* `readFitzpatrickSkinType`: output = I|II|III|IV|V|VI|unknown
* `readWeight`: 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 amount
* `readHeight`: pass in unit (mm=millimeter, cm=centimeter, m=meter, in=inch, ft=foot)
Expand Down
18 changes: 14 additions & 4 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ <h1>Apache Cordova</h1>
<button onclick="readGender()">Read gender</button>
<br/><br/>
<button onclick="readBloodType()">Read bloodtype</button>
&nbsp;&nbsp;
<button onclick="readFitzpatrickSkinType()">Fitzp. Skin type</button>
<br/><br/>
<button onclick="querySampleType()">Query Sample</button>
<br/><br/>
Expand Down Expand Up @@ -113,9 +115,9 @@ <h1>Apache Cordova</h1>
function requestAuthorization() {
window.plugins.healthkit.requestAuthorization(
{
'readTypes': ['HKCharacteristicTypeIdentifierDateOfBirth',
readTypes: ['HKCharacteristicTypeIdentifierDateOfBirth',
'HKCategoryTypeIdentifierSleepAnalysis', 'HKQuantityTypeIdentifierActiveEnergyBurned', 'HKQuantityTypeIdentifierHeight'],
'writeTypes': ['HKQuantityTypeIdentifierDietaryEnergyConsumed', 'HKQuantityTypeIdentifierDietaryFatTotal', 'HKQuantityTypeIdentifierStepCount', 'HKQuantityTypeIdentifierActiveEnergyBurned', 'HKQuantityTypeIdentifierHeight', 'HKQuantityTypeIdentifierDistanceCycling']
writeTypes: ['HKQuantityTypeIdentifierDietaryEnergyConsumed', 'HKQuantityTypeIdentifierDietaryFatTotal', 'HKQuantityTypeIdentifierStepCount', 'HKQuantityTypeIdentifierActiveEnergyBurned', 'HKQuantityTypeIdentifierHeight', 'HKQuantityTypeIdentifierDistanceCycling']
},
callback,
callback
Expand Down Expand Up @@ -153,6 +155,13 @@ <h1>Apache Cordova</h1>
);
}

function readFitzpatrickSkinType() {
window.plugins.healthkit.readFitzpatrickSkinType(
callback,
callback
);
}

function saveWeight() {
window.plugins.healthkit.saveWeight({
'requestReadPermission': false, // use if your app doesn't need to read
Expand Down Expand Up @@ -228,8 +237,9 @@ <h1>Apache Cordova</h1>
{
'startDate': new Date(new Date().getTime() - 3 * 24 * 60 * 60 * 1000), // three days ago
'endDate': new Date(), // now
'sampleType': 'HKQuantityTypeIdentifierStepCount', // anything in HealthKit/HKTypeIdentifiers.h
'unit': 'count' // make sure this is compatible with the sampleType
'sampleType': 'HKQuantityTypeIdentifierBasalBodyTemperature',
//'sampleType': 'HKQuantityTypeIdentifierStepCount', // anything in HealthKit/HKTypeIdentifiers.h
'unit': 'degF' // make sure this is compatible with the sampleType
},
callback,
callback
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.4.2",
"version": "0.5.0",
"name": "com.telerik.plugins.healthkit",
"cordova_name": "HealthKit",
"description": "Interact with the iOS HealthKit SDK.",
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="com.telerik.plugins.healthkit"
version="0.4.2">
version="0.5.0">

<name>HealthKit</name>

Expand Down
1 change: 1 addition & 0 deletions src/ios/HealthKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- (void) readGender:(CDVInvokedUrlCommand*)command;
- (void) readBloodType:(CDVInvokedUrlCommand*)command;
- (void) readDateOfBirth:(CDVInvokedUrlCommand*)command;
- (void) readFitzpatrickSkinType:(CDVInvokedUrlCommand*)command;

- (void) saveWeight:(CDVInvokedUrlCommand*)command;
- (void) readWeight:(CDVInvokedUrlCommand*)command;
Expand Down
Loading

0 comments on commit 5eb7bdb

Please sign in to comment.