Commit 531e1b32 authored by Evgeny Evstropov's avatar Evgeny Evstropov

update docs, change one of the returning key from getSamples

parent 0b536cff
...@@ -156,7 +156,7 @@ ...@@ -156,7 +156,7 @@
} }
NSDictionary *elem = @{ NSDictionary *elem = @{
@"activityName" : [NSNumber numberWithInt:[sample workoutActivityType]], @"activityNameId" : [NSNumber numberWithInt:[sample workoutActivityType]],
@"calories" : @(energy), @"calories" : @(energy),
@"tracked" : @(isTracked), @"tracked" : @(isTracked),
@"sourceName" : [[[sample sourceRevision] source] name], @"sourceName" : [[[sample sourceRevision] source] name],
......
...@@ -100,8 +100,10 @@ AppleHealthKit.initHealthKit(options: Object, (err: string, results: Object) => ...@@ -100,8 +100,10 @@ AppleHealthKit.initHealthKit(options: Object, (err: string, results: Object) =>
* Base Methods * Base Methods
* [isAvailable](/docs/isAvailable().md) * [isAvailable](/docs/isAvailable().md)
* [initHealthKit](/docs/initHealthKit().md) * [initHealthKit](/docs/initHealthKit().md)
* checkSharePermission
* Realtime Methods * Realtime Methods
* [initStepCountObserver](/docs/initStepCountObserver().md) * [initStepCountObserver](/docs/initStepCountObserver().md)
* [setObserverForType](/docs/setObserverForType().md)
* Read Methods * Read Methods
* [getActiveEnergyBurned](/docs/getActiveEnergyBurned().md) * [getActiveEnergyBurned](/docs/getActiveEnergyBurned().md)
* [getBasalEnergyBurned](/docs/getBasalEnergyBurned().md) * [getBasalEnergyBurned](/docs/getBasalEnergyBurned().md)
...@@ -128,6 +130,7 @@ AppleHealthKit.initHealthKit(options: Object, (err: string, results: Object) => ...@@ -128,6 +130,7 @@ AppleHealthKit.initHealthKit(options: Object, (err: string, results: Object) =>
* [getSleepSamples](/docs/getsleepsamples().md) * [getSleepSamples](/docs/getsleepsamples().md)
* [getStepCount](/docs/getStepCount().md) * [getStepCount](/docs/getStepCount().md)
* [getWeightSamples](/docs/getweightsamples().md) * [getWeightSamples](/docs/getweightsamples().md)
* [getSamples](docs/getSamples().md)
* Write Methods * Write Methods
* [saveBmi](/docs/savebmi().md) * [saveBmi](/docs/savebmi().md)
* [saveHeight](/docs/saveheight().md) * [saveHeight](/docs/saveheight().md)
......
Query to get all activities of given type with extended information about it.
```javascript 1.7
let options = {
startDate: (new Date(2016,4,27)).toISOString(),
endDate: (new Date()).toISOString(),
type: 'Walking', // one of: ['Walking', 'StairClimbing', 'Running', 'Cycling', 'Workout']
};
```
The callback function will be called with a `samples` array containing objects with *value*, *startDate*, and *endDate* fields
```javascript 1.7
AppleHealthKit.getSamples(options, (err: Object, results: Array<Object>) => {
if (err) {
return;
}
console.log(results)
});
```
Resulting object has different fields for different types.
In case of workout:
```
{
activityNameId: Number, // [NSNumber numberWithInt:[sample workoutActivityType]]
calories: Number, // [[sample totalEnergyBurned] doubleValueForUnit:[HKUnit kilocalorieUnit]]
tracked: Boolean, // [[sample metadata][HKMetadataKeyWasUserEntered] intValue] !== 1
sourceName: String, // [[[sample sourceRevision] source] name]
sourceId: String, // [[[sample sourceRevision] source] bundleIdentifier]
device: String, // [[sample sourceRevision] productType] or 'iPhone'
distance: Number, // [[sample totalDistance] doubleValueForUnit:[HKUnit mileUnit]]
start: String, // [RCTAppleHealthKit buildISO8601StringFromDate:sample.startDate];
end: String, // [RCTAppleHealthKit buildISO8601StringFromDate:sample.endDate];
}
```
for other types:
```
{
activityNameId: Number, // [NSNumber numberWithInt:[sample workoutActivityType]]
tracked: Boolean, // [[sample metadata][HKMetadataKeyWasUserEntered] intValue] !== 1
sourceName: String, // [[[sample sourceRevision] source] name]
sourceId: String, // [[[sample sourceRevision] source] bundleIdentifier]
device: String, // [[sample sourceRevision] productType] or 'iPhone'
start: String, // [RCTAppleHealthKit buildISO8601StringFromDate:sample.startDate];
end: String, // [RCTAppleHealthKit buildISO8601StringFromDate:sample.endDate];
//based on required type, one of the following will be present.
distance: Number, // [[sample totalDistance] doubleValueForUnit:[HKUnit mileUnit]]
calories: Number, // [[sample totalEnergyBurned] doubleValueForUnit:[HKUnit kilocalorieUnit]]
}
```
Will listen for any updates in a given type data in healthKit and call app.
type - one of the `['Walking', 'StairClimbing', 'Running', 'Cycling', 'Workout']`
```javascript 1.8
import { NativeAppEventEmitter } from 'react-native';
//...//
AppleHealthKit.setObserver({ type: 'Walking' });
NativeAppEventEmitter.addListener(
'observer',
callback
);
```
So, callback would be call when new data of given type appears. When it happens, in order to get new info
need to call getSamples() function with proper arguments.
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