Commit 671b3bf6 authored by Terrillo Walls's avatar Terrillo Walls

getLatestWeight updated

parent 329c5c18
...@@ -153,41 +153,14 @@ The available HealthKit permissions to use with `initHealthKit` ...@@ -153,41 +153,14 @@ The available HealthKit permissions to use with `initHealthKit`
These permissions are exported as constants of the `rn-apple-healthkit` module. These permissions are exported as constants of the `rn-apple-healthkit` module.
```javascript
import AppleHealthKit from 'rn-apple-healthkit';
...
// get the available permissions from AppleHealthKit.Constants object
const PERMS = AppleHealthKit.Constants.Permissions;
// setup healthkit read/write permissions using PERMS
const healthKitOptions = {
permissions: {
read: [
PERMS.StepCount,
PERMS.Height,
],
write: [
PERMS.StepCount
],
}
};
...
```
Options
-------
## Methods
Methods
-------
#### **`isAvailable`** #### **`isAvailable`**
Check if HealthKit is available on the device. Check if HealthKit is available on the device.
```javascript ```javascript
import AppleHealthKit from 'rn-apple-healthkit';
AppleHealthKit.isAvailable((err: Object, available: boolean) => { AppleHealthKit.isAvailable((err: Object, available: boolean) => {
if(available){ if(available){
// ... // ...
...@@ -219,7 +192,7 @@ let options = { ...@@ -219,7 +192,7 @@ let options = {
```javascript ```javascript
AppleHealthKit.initHealthKit(options: Object, (err: string, res: Object) => { AppleHealthKit.initHealthKit(options: Object, (err: string, res: Object) => {
if(err) { if (err) {
console.log("error initializing healthkit: ", err); console.log("error initializing healthkit: ", err);
return; return;
} }
...@@ -504,24 +477,32 @@ ___ ...@@ -504,24 +477,32 @@ ___
Get the most recent weight sample. Get the most recent weight sample.
On success, the callback function will be provided with a `weight` object containing the weight `value`, and the `startDate` and `endDate` of the weight sample. *Note: startDate and endDate will be the same as weight samples are saved at a specific point in time.* On success, the callback function will be provided with a `weight` object containing the weight `value`, and the `startDate` and `endDate` of the weight sample. *Note: startDate and endDate will be the same as weight samples are saved at a specific point in time.*
```javascript
{
value: 200,
startDate: '2016-07-08T12:00:00.000-0400',
endDate: '2016-07-08T12:00:00.000-0400'
}
```
```javascript ```javascript
AppleHealthKit.getLatestWeight(null, (err: string, weight: Object) => { AppleHealthKit.initHealthKit(null: Object, (err: string, res: Object) => {
if(err){
let options = {
unit: 'pound'
};
AppleHealthKit.getLatestWeight(options, (err: string, weight: Object) => {
if (err) {
console.log("error getting latest weight: ", err); console.log("error getting latest weight: ", err);
return; return;
} }
// use weight.value, weight.startDate, etc ... console.log(weight)
});
}); });
``` ```
```javascript
{
value: 200,
startDate: '2016-07-08T12:00:00.000-0400',
endDate: '2016-07-08T12:00:00.000-0400'
}
```
___ ___
#### **`getWeightSamples`** #### **`getWeightSamples`**
......
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