Skip to content

Commit

Permalink
change back default to imperial system, add activity name field, fix …
Browse files Browse the repository at this point in the history
…docs
  • Loading branch information
EJohnF committed Feb 26, 2019
1 parent 3f91987 commit 61a1e7c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 37 deletions.
19 changes: 4 additions & 15 deletions RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ - (void)body_getLatestWeight:(NSDictionary *)input callback:(RCTResponseSenderBl
{
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
completion:^(HKQuantity *mostRecentQuantity, NSDate *startDate, NSDate *endDate, NSError *error) {
Expand Down Expand Up @@ -151,11 +148,7 @@ - (void)body_saveBodyMassIndex:(NSDictionary *)input callback:(RCTResponseSender
- (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
Expand Down Expand Up @@ -217,11 +210,7 @@ - (void)body_saveHeight:(NSDictionary *)input callback:(RCTResponseSenderBlock)c
{
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];
Expand Down
3 changes: 2 additions & 1 deletion RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ - (void)fetchSamplesOfType:(HKSampleType *)type
}

NSDictionary *elem = @{
@"activityNameId" : [NSNumber numberWithInt:[sample workoutActivityType]],
@"activityId" : [NSNumber numberWithInt:[sample workoutActivityType]],
@"activityName" : type,
@"calories" : @(energy),
@"tracked" : @(isTracked),
@"sourceName" : [[[sample sourceRevision] source] name],
Expand Down
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,34 +108,34 @@ AppleHealthKit.initHealthKit(options: Object, (err: string, results: Object) =>
* [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)

Expand Down
4 changes: 2 additions & 2 deletions docs/getSamples().md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ Resulting object has different fields for different types.
In case of workout:
```
{
activityNameId: Number, // [NSNumber numberWithInt:[sample workoutActivityType]]
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]
Expand All @@ -37,7 +38,6 @@ In case of workout:
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]
Expand Down

0 comments on commit 61a1e7c

Please sign in to comment.