Commit 4bf7859d authored by Greg Wilson's avatar Greg Wilson Committed by GitHub

Update README.md

added partial sample of fetching and saving weight
parent 1d43d0a7
...@@ -41,6 +41,36 @@ AppleHealthKit.initHealthKit(healthKitOptions, (err, res) => { ...@@ -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/ [Apple HealthKit]: https://developer.apple.com/healthkit/
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