Commit 749ec2bc authored by Terrillo Walls's avatar Terrillo Walls

Merge branch 'feature/moreDailyMethods' of https://github.com/toml0006/rn-apple-healthkit

parents 26cd0c6d ca5fd19c
...@@ -16,7 +16,10 @@ ...@@ -16,7 +16,10 @@
- (void)fitness_saveSteps:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback; - (void)fitness_saveSteps:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
- (void)fitness_initializeStepEventObserver:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback; - (void)fitness_initializeStepEventObserver:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
- (void)fitness_getDistanceWalkingRunningOnDay:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback; - (void)fitness_getDistanceWalkingRunningOnDay:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
- (void)fitness_getDailyDistanceWalkingRunningSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
- (void)fitness_getDistanceCyclingOnDay:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback; - (void)fitness_getDistanceCyclingOnDay:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
- (void)fitness_getDailyDistanceCyclingSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
- (void)fitness_getFlightsClimbedOnDay:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback; - (void)fitness_getFlightsClimbedOnDay:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
- (void)fitness_getDailyFlightsClimbedSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
@end @end
...@@ -165,6 +165,35 @@ ...@@ -165,6 +165,35 @@
}]; }];
} }
- (void)fitness_getDailyDistanceWalkingRunningSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback
{
HKUnit *unit = [RCTAppleHealthKit hkUnitFromOptions:input key:@"unit" withDefault:[HKUnit meterUnit]];
NSUInteger limit = [RCTAppleHealthKit uintFromOptions:input key:@"limit" withDefault:HKObjectQueryNoLimit];
BOOL ascending = [RCTAppleHealthKit boolFromOptions:input key:@"ascending" withDefault:false];
NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil];
NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]];
if(startDate == nil){
callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]);
return;
}
HKQuantityType *quantityType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDistanceWalkingRunning];
[self fetchCumulativeSumStatisticsCollection:quantityType
unit:unit
startDate:startDate
endDate:endDate
ascending:ascending
limit:limit
completion:^(NSArray *arr, NSError *err){
if (err != nil) {
NSLog(@"error with fetchCumulativeSumStatisticsCollection: %@", err);
callback(@[RCTMakeError(@"error with fetchCumulativeSumStatisticsCollection", err, nil)]);
return;
}
callback(@[[NSNull null], arr]);
}];
}
- (void)fitness_getDistanceCyclingOnDay:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback - (void)fitness_getDistanceCyclingOnDay:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback
{ {
...@@ -190,6 +219,35 @@ ...@@ -190,6 +219,35 @@
}]; }];
} }
- (void)fitness_getDailyDistanceCyclingSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback
{
HKUnit *unit = [RCTAppleHealthKit hkUnitFromOptions:input key:@"unit" withDefault:[HKUnit meterUnit]];
NSUInteger limit = [RCTAppleHealthKit uintFromOptions:input key:@"limit" withDefault:HKObjectQueryNoLimit];
BOOL ascending = [RCTAppleHealthKit boolFromOptions:input key:@"ascending" withDefault:false];
NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil];
NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]];
if(startDate == nil){
callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]);
return;
}
HKQuantityType *quantityType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDistanceCycling];
[self fetchCumulativeSumStatisticsCollection:quantityType
unit:unit
startDate:startDate
endDate:endDate
ascending:ascending
limit:limit
completion:^(NSArray *arr, NSError *err){
if (err != nil) {
NSLog(@"error with fetchCumulativeSumStatisticsCollection: %@", err);
callback(@[RCTMakeError(@"error with fetchCumulativeSumStatisticsCollection", err, nil)]);
return;
}
callback(@[[NSNull null], arr]);
}];
}
- (void)fitness_getFlightsClimbedOnDay:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback - (void)fitness_getFlightsClimbedOnDay:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback
{ {
...@@ -215,4 +273,34 @@ ...@@ -215,4 +273,34 @@
}]; }];
} }
- (void)fitness_getDailyFlightsClimbedSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback
{
HKUnit *unit = [RCTAppleHealthKit hkUnitFromOptions:input key:@"unit" withDefault:[HKUnit countUnit]];
NSUInteger limit = [RCTAppleHealthKit uintFromOptions:input key:@"limit" withDefault:HKObjectQueryNoLimit];
BOOL ascending = [RCTAppleHealthKit boolFromOptions:input key:@"ascending" withDefault:false];
NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil];
NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]];
if(startDate == nil){
callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]);
return;
}
HKQuantityType *quantityType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierFlightsClimbed];
[self fetchCumulativeSumStatisticsCollection:quantityType
unit:unit
startDate:startDate
endDate:endDate
ascending:ascending
limit:limit
completion:^(NSArray *arr, NSError *err){
if (err != nil) {
NSLog(@"error with fetchCumulativeSumStatisticsCollection: %@", err);
callback(@[RCTMakeError(@"error with fetchCumulativeSumStatisticsCollection", err, nil)]);
return;
}
callback(@[[NSNull null], arr]);
}];
}
@end @end
...@@ -122,16 +122,31 @@ RCT_EXPORT_METHOD(getDistanceWalkingRunning:(NSDictionary *)input callback:(RCTR ...@@ -122,16 +122,31 @@ RCT_EXPORT_METHOD(getDistanceWalkingRunning:(NSDictionary *)input callback:(RCTR
[self fitness_getDistanceWalkingRunningOnDay:input callback:callback]; [self fitness_getDistanceWalkingRunningOnDay:input callback:callback];
} }
RCT_EXPORT_METHOD(getDailyDistanceWalkingRunningSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self fitness_getDailyDistanceWalkingRunningSamples:input callback:callback];
}
RCT_EXPORT_METHOD(getDistanceCycling:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback) RCT_EXPORT_METHOD(getDistanceCycling:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{ {
[self fitness_getDistanceCyclingOnDay:input callback:callback]; [self fitness_getDistanceCyclingOnDay:input callback:callback];
} }
RCT_EXPORT_METHOD(getDailyDistanceCyclingSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self fitness_getDailyDistanceCyclingSamples:input callback:callback];
}
RCT_EXPORT_METHOD(getFlightsClimbed:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback) RCT_EXPORT_METHOD(getFlightsClimbed:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{ {
[self fitness_getFlightsClimbedOnDay:input callback:callback]; [self fitness_getFlightsClimbedOnDay:input callback:callback];
} }
RCT_EXPORT_METHOD(getDailyFlightsClimbedSamples:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{
[self fitness_getDailyFlightsClimbedSamples:input callback:callback];
}
RCT_EXPORT_METHOD(saveFood:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback) RCT_EXPORT_METHOD(saveFood:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback)
{ {
[self saveFood:input callback:callback]; [self saveFood:input callback:callback];
......
...@@ -104,6 +104,9 @@ AppleHealthKit.initHealthKit(options: Object, (err: string, results: Object) => ...@@ -104,6 +104,9 @@ AppleHealthKit.initHealthKit(options: Object, (err: string, results: Object) =>
* [getBloodGlucoseSamples](https://github.com/terrillo/rn-apple-healthkit/wiki/getbloodglucosesamples()) * [getBloodGlucoseSamples](https://github.com/terrillo/rn-apple-healthkit/wiki/getbloodglucosesamples())
* [getBloodPressureSamples](https://github.com/terrillo/rn-apple-healthkit/wiki/getbloodpressuresamples()) * [getBloodPressureSamples](https://github.com/terrillo/rn-apple-healthkit/wiki/getbloodpressuresamples())
* [getBodyTemperatureSamples](https://github.com/terrillo/rn-apple-healthkit/wiki/getbodytemperaturesamples()) * [getBodyTemperatureSamples](https://github.com/terrillo/rn-apple-healthkit/wiki/getbodytemperaturesamples())
* [getDailyDistanceCyclingSamples]()
* [getDailyDistanceWalkingRunningSamples]()
* [getDailyFlightsClimbedSamples]()
* [getDailyStepCountSamples](https://github.com/terrillo/rn-apple-healthkit/wiki/getDailyStepCountSamples()) * [getDailyStepCountSamples](https://github.com/terrillo/rn-apple-healthkit/wiki/getDailyStepCountSamples())
* [getDateOfBirth](https://github.com/terrillo/rn-apple-healthkit/wiki/getDateOfBirth()) * [getDateOfBirth](https://github.com/terrillo/rn-apple-healthkit/wiki/getDateOfBirth())
* [getDistanceCycling](https://github.com/terrillo/rn-apple-healthkit/wiki/getdistancecycling()) * [getDistanceCycling](https://github.com/terrillo/rn-apple-healthkit/wiki/getdistancecycling())
......
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