Commit a79fc010 authored by Furyou81's avatar Furyou81

merge

parents 67679c39 8c189e9c
......@@ -18,10 +18,7 @@
{
HKQuantityType *weightType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierBodyMass];
HKUnit *unit = [RCTAppleHealthKit hkUnitFromOptions:input key:@"unit" withDefault:[HKUnit gramUnitWithMetricPrefix:HKMetricPrefixKilo]];
if(unit == nil){
unit = [HKUnit gramUnit];
}
HKUnit *unit = [RCTAppleHealthKit hkUnitFromOptions:input key:@"unit" withDefault:[HKUnit poundUnit]];
[self fetchMostRecentQuantitySampleOfType:weightType
predicate:nil
......@@ -151,11 +148,7 @@
- (void)body_getLatestHeight:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback
{
HKQuantityType *heightType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierHeight];
HKUnit *unit = [RCTAppleHealthKit hkUnitFromOptions:input key:@"unit" withDefault:[HKUnit meterUnitWithMetricPrefix:HKMetricPrefixCenti]];;
if(unit == nil){
unit = [HKUnit meterUnit];
}
HKUnit *unit = [RCTAppleHealthKit hkUnitFromOptions:input key:@"unit" withDefault:[HKUnit inchUnit]];;
[self fetchMostRecentQuantitySampleOfType:heightType
predicate:nil
......@@ -217,11 +210,7 @@
{
double height = [RCTAppleHealthKit doubleValueFromOptions:input];
NSDate *sampleDate = [RCTAppleHealthKit dateFromOptionsDefaultNow:input];
HKUnit *heightUnit = [RCTAppleHealthKit hkUnitFromOptions:input key:@"unit" withDefault:[HKUnit inchUnit]];;
if(heightUnit == nil){
heightUnit = [HKUnit inchUnit];
}
HKUnit *heightUnit = [RCTAppleHealthKit hkUnitFromOptions:input key:@"unit" withDefault:[HKUnit inchUnit]];
HKQuantity *heightQuantity = [HKQuantity quantityWithUnit:heightUnit doubleValue:height];
HKQuantityType *heightType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierHeight];
......
......@@ -156,7 +156,8 @@
}
NSDictionary *elem = @{
@"activityName" : [NSNumber numberWithInt:[sample workoutActivityType]],
@"activityId" : [NSNumber numberWithInt:[sample workoutActivityType]],
@"activityName" : type,
@"calories" : @(energy),
@"tracked" : @(isTracked),
@"sourceName" : [[[sample sourceRevision] source] name],
......
......@@ -77,6 +77,12 @@ AppleHealthKit.initHealthKit(options: Object, (err: string, results: Object) =>
```
## Changelog
0.6.5v
- Enable fetching basal energy [#23](https://github.com/terrillo/rn-apple-healthkit/pull/23)
- remove checkPermission functions in order to use from PR [#69](https://github.com/terrillo/rn-apple-healthkit/pull/69)
- Added correct link to permissions. [#73](https://github.com/terrillo/rn-apple-healthkit/pull/73)
- Add unified way to get workouts + convert Activity Types to name + isTracked flag [#25](https://github.com/terrillo/rn-apple-healthkit/pull/25)
0.6.4v
- Basal energy ([#23](https://github.com/terrillo/rn-apple-healthkit/pull/23))
- Fixed issues with saving weight in the past
......@@ -95,44 +101,46 @@ AppleHealthKit.initHealthKit(options: Object, (err: string, results: Object) =>
## Wiki
* [Installation](/docs/Install)
* [Documentation](#documentation)
* [Permissions](#permissions)
* [Permissions](#supported-apple-permissions)
* [Units](#units)
* Base Methods
* [isAvailable](/docs/isAvailable().md)
* [initHealthKit](/docs/initHealthKit().md)
* Realtime Methods
* [initStepCountObserver](/docs/initStepCountObserver().md)
* [setObserver](/docs/setObserver().md)
* Read Methods
* [getActiveEnergyBurned](/docs/getActiveEnergyBurned().md)
* [getBasalEnergyBurned](/docs/getBasalEnergyBurned().md)
* [getBiologicalSex](/docs/getBiologicalSex().md)
* [getBloodGlucoseSamples](/docs/getbloodglucosesamples().md)
* [getBloodPressureSamples](/docs/getbloodpressuresamples().md)
* [getBodyTemperatureSamples](/docs/getbodytemperaturesamples().md)
* [getDailyDistanceCyclingSamples]()
* [getBloodGlucoseSamples](/docs/getBloodglucoseSamples().md)
* [getBloodPressureSamples](/docs/getBloodPressureSamples().md)
* [getBodyTemperatureSamples](/docs/getBodyTemperatureSamples().md)
* [getDailyDistanceCyclingSamples](/docs/getDailyDistanceCyclingSamples().md)
* [getDailyDistanceWalkingRunningSamples](/docs/getDailyDistanceWalkingRunningSamples().md)
* [getDailyFlightsClimbedSamples](/docs/getDailyFlightsClimbedSamples().md)
* [getDailyStepCountSamples](/docs/getDailyStepCountSamples().md)
* [getDateOfBirth](/docs/getDateOfBirth().md)
* [getDistanceCycling](/docs/getdistancecycling().md)
* [getDistanceCycling](/docs/getDistanceCycling().md)
* [getDistanceWalkingRunning](/docs/getDistanceWalkingRunning().md)
* [getFlightsClimbed](/docs/getflightsclimbed().md)
* [getHeartRateSamples](/docs/getheartratesamples().md)
* [getHeightSamples](/docs/getheightsamples().md)
* [getLatestBmi](/docs/getlatestbmi().md)
* [getLatestBodyFatPercentage](/docs/getlatestbodyfatpercentage().md)
* [getLatestHeight](/docs/getlatestheight().md)
* [getLatestLeanBodyMass](/docs/getlatestleanbodymass().md)
* [getLatestWeight](/docs/getlatestweight().md)
* [getRespiratoryRateSamples](/docs/getrespiratoryratesamples().md)
* [getSleepSamples](/docs/getsleepsamples().md)
* [getFlightsClimbed](/docs/getFlightsClimbed().md)
* [getHeartRateSamples](/docs/getHeartRateSamples().md)
* [getHeightSamples](/docs/getHeightSamples().md)
* [getLatestBmi](/docs/getLatestBmi().md)
* [getLatestBodyFatPercentage](/docs/getLatestBodyFatPercentage().md)
* [getLatestHeight](/docs/getLatestHeight().md)
* [getLatestLeanBodyMass](/docs/getLatestLeanBodyMass().md)
* [getLatestWeight](/docs/getLatestWeight().md)
* [getRespiratoryRateSamples](/docs/getRespiratoryRateSamples().md)
* [getSleepSamples](/docs/getSleepSamples().md)
* [getStepCount](/docs/getStepCount().md)
* [getWeightSamples](/docs/getweightsamples().md)
* [getWeightSamples](/docs/getWeightSamples().md)
* [getSamples](docs/getSamples().md)
* Write Methods
* [saveBmi](/docs/savebmi().md)
* [saveHeight](/docs/saveheight().md)
* [saveBmi](/docs/saveBmi().md)
* [saveHeight](/docs/saveHeight().md)
* [saveMindfulSession](/docs/saveMindfulSession().md)
* [saveWeight](/docs/saveweight().md)
* [saveWeight](/docs/saveWeight().md)
* [saveSteps](/docs/saveSteps().md)
* [References](#references)
......
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:
```
{
activityId: Number, // [NSNumber numberWithInt:[sample workoutActivityType]]
activityName: Number, // [RCTAppleHealthKit stringForHKWorkoutActivityType:[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:
```
{
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.
{
"name": "rn-apple-healthkit",
"version": "0.6.4",
"version": "0.6.5",
"description": "A React Native package for interacting with Apple HealthKit",
"main": "index.js",
"repository": {
......
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