From 4bf7859dfda654a7a721d58971333ee0822db317 Mon Sep 17 00:00:00 2001 From: Greg Wilson Date: Mon, 27 Jun 2016 02:23:02 -0400 Subject: [PATCH] Update README.md added partial sample of fetching and saving weight --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index 0ff0e3e..02c2989 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,36 @@ AppleHealthKit.initHealthKit(healthKitOptions, (err, res) => { ``` +When the module has been successfully initialized you can read and write HealthKit data + +```javascript +var AppleHealthKit = require('react-native-apple-healthkit'); +var _ = require('lodash'); + +... + +AppleHealthKit.getCurrentWeight(null, (err, weight) => { + if(err){ + console.log("error getting current weight: ", err); + return; + } + weight = _.round(weight,1); + // do something with the weight... +}); + +... + +let myWeight = 200; +AppleHealthKit.saveWeight({weight:myWeight}, (err, res) => { + if(err){ + console.log("error saving weight to healthkit: ", err); + return; + } + // weight successfully saved +}); + + +``` [Apple HealthKit]: https://developer.apple.com/healthkit/ -- 2.26.2