Commit 1029da31 authored by Greg Wilson's avatar Greg Wilson

updated readme

parent 86372b03
...@@ -27,6 +27,7 @@ A React Native bridge module for interacting with [Apple HealthKit] data. ...@@ -27,6 +27,7 @@ A React Native bridge module for interacting with [Apple HealthKit] data.
* [getWeightSamples](#getweightsamples) * [getWeightSamples](#getweightsamples)
* [saveWeight](#saveweight) * [saveWeight](#saveweight)
* [getLatestHeight](#getlatestheight) * [getLatestHeight](#getlatestheight)
* [getHeightSamples](#getheightsamples)
* [saveHeight](#saveheight) * [saveHeight](#saveheight)
* [getLatestBmi](#getlatestbmi) * [getLatestBmi](#getlatestbmi)
* [saveBmi](#savebmi) * [saveBmi](#savebmi)
...@@ -363,6 +364,39 @@ AppleHealthKit.getLatestHeight(null, (err: string, height: number) => { ...@@ -363,6 +364,39 @@ AppleHealthKit.getLatestHeight(null, (err: string, height: number) => {
___ ___
#### **`getHeightSamples`**
query for height samples. the options object is used to setup a query to retrieve relevant samples.
```javascript
let options = {
unit: 'inch', // optional; default 'inch'
startDate: (new Date(2016,4,27)).toISOString(), // required
endDate: (new Date()).toISOString(), // optional; default now
ascending: false, // optional; default false
limit:10, // optional; default no limit
};
```
the callback function will be called with a `samples` array containing objects with *value*, *startDate*, and *endDate* fields
```javascript
// samples is array of objects
[
{value: 74.02, startDate: '2016-06-29T17:55:00.000-0400', endDate: '2016-06-29T17:55:00.000-0400' },
{value: 74, startDate: '2016-03-12T13:22:00.000-0400', endDate: '2016-03-12T13:22:00.000-0400' },
...
]
```
```javascript
AppleHealthKit.getHeightSamples(options, (err: Object, samples: Array<Object>) => {
if(this._handleHealthKitError(err, 'getHeightSamples')){
return;
}
// use samples ...
});
```
___
#### **`saveHeight`** #### **`saveHeight`**
save a numeric height value to HealthKit save a numeric height value to HealthKit
......
...@@ -28,7 +28,8 @@ const HKOPTIONS = { ...@@ -28,7 +28,8 @@ const HKOPTIONS = {
read: [ read: [
RPERMS.StepCount, RPERMS.StepCount,
RPERMS.DistanceWalkingRunning, RPERMS.DistanceWalkingRunning,
RPERMS.FlightsClimbed RPERMS.FlightsClimbed,
RPERMS.Height,
], ],
write: [WPERMS.StepCount], write: [WPERMS.StepCount],
} }
...@@ -102,6 +103,20 @@ class Home extends Component { ...@@ -102,6 +103,20 @@ class Home extends Component {
console.log('getFlightsClimbed -res-> ', res); console.log('getFlightsClimbed -res-> ', res);
}); });
let sampleOptions = {
startDate: (new Date(2016,4,1)).toISOString(),
};
AppleHealthKit.getHeightSamples(sampleOptions, (err, samples) => {
if(this._handleHKError(err, 'getHeightSamples')){
return;
}
console.log('getHeightSamples: ', samples);
});
} }
_onPressItem(key) { _onPressItem(key) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment