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
],
}
};
...
```
## Methods
Options
-------
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,6 +477,24 @@ ___ ...@@ -504,6 +477,24 @@ ___
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
AppleHealthKit.initHealthKit(null: Object, (err: string, res: Object) => {
let options = {
unit: 'pound'
};
AppleHealthKit.getLatestWeight(options, (err: string, weight: Object) => {
if (err) {
console.log("error getting latest weight: ", err);
return;
}
console.log(weight)
});
});
```
```javascript ```javascript
{ {
value: 200, value: 200,
...@@ -512,16 +503,6 @@ On success, the callback function will be provided with a `weight` object contai ...@@ -512,16 +503,6 @@ On success, the callback function will be provided with a `weight` object contai
} }
``` ```
```javascript
AppleHealthKit.getLatestWeight(null, (err: string, weight: Object) => {
if(err){
console.log("error getting latest weight: ", err);
return;
}
// use weight.value, weight.startDate, etc ...
});
```
___ ___
#### **`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