From 1029da311ad7e8dc7d6b0f0424fd0d068675c472 Mon Sep 17 00:00:00 2001 From: Greg Wilson Date: Thu, 30 Jun 2016 20:49:56 -0400 Subject: [PATCH] updated readme --- README.md | 34 +++++++++++++++++++ .../StepsDemo/app/components/home/index.js | 17 +++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 83c5120..2c4d0a5 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ A React Native bridge module for interacting with [Apple HealthKit] data. * [getWeightSamples](#getweightsamples) * [saveWeight](#saveweight) * [getLatestHeight](#getlatestheight) + * [getHeightSamples](#getheightsamples) * [saveHeight](#saveheight) * [getLatestBmi](#getlatestbmi) * [saveBmi](#savebmi) @@ -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) => { + if(this._handleHealthKitError(err, 'getHeightSamples')){ + return; + } + // use samples ... +}); +``` + +___ + #### **`saveHeight`** save a numeric height value to HealthKit diff --git a/examples/StepsDemo/app/components/home/index.js b/examples/StepsDemo/app/components/home/index.js index 383fc81..933aab9 100644 --- a/examples/StepsDemo/app/components/home/index.js +++ b/examples/StepsDemo/app/components/home/index.js @@ -28,7 +28,8 @@ const HKOPTIONS = { read: [ RPERMS.StepCount, RPERMS.DistanceWalkingRunning, - RPERMS.FlightsClimbed + RPERMS.FlightsClimbed, + RPERMS.Height, ], write: [WPERMS.StepCount], } @@ -102,6 +103,20 @@ class Home extends Component { 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) { -- 2.26.2