-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* getActiveEnergyBurned * Docs update * Version update * Docs fix
- Loading branch information
Terrillo Walls
authored
Oct 4, 2017
1 parent
b198cbd
commit f50b6e1
Showing
6 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// RCTAppleHealthKit+Methods_Activity.h | ||
// RCTAppleHealthKit | ||
// | ||
// Created by Alexander Vallorosi on 4/27/17. | ||
// Copyright © 2017 Alexander Vallorosi. All rights reserved. | ||
// | ||
#import "RCTAppleHealthKit.h" | ||
|
||
@interface RCTAppleHealthKit (Methods_Activity) | ||
|
||
- (void)activity_getActiveEnergyBurned:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// RCTAppleHealthKit+Methods_Activity.m | ||
// RCTAppleHealthKit | ||
// | ||
// Created by Alexander Vallorosi on 4/27/17. | ||
// Copyright © 2017 Alexander Vallorosi. All rights reserved. | ||
// | ||
|
||
#import "RCTAppleHealthKit+Methods_Activity.h" | ||
#import "RCTAppleHealthKit+Queries.h" | ||
#import "RCTAppleHealthKit+Utils.h" | ||
|
||
@implementation RCTAppleHealthKit (Methods_Activity) | ||
|
||
- (void)activity_getActiveEnergyBurned:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback | ||
{ | ||
HKQuantityType *activeEnergyType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierActiveEnergyBurned]; | ||
NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil]; | ||
NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]]; | ||
HKUnit *cal = [HKUnit kilocalorieUnit]; | ||
|
||
if(startDate == nil){ | ||
callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]); | ||
return; | ||
} | ||
NSPredicate * predicate = [RCTAppleHealthKit predicateForSamplesBetweenDates:startDate endDate:endDate]; | ||
|
||
[self fetchQuantitySamplesOfType:activeEnergyType | ||
unit:cal | ||
predicate:predicate | ||
ascending:false | ||
limit:HKObjectQueryNoLimit | ||
completion:^(NSArray *results, NSError *error) { | ||
if(results){ | ||
callback(@[[NSNull null], results]); | ||
return; | ||
} else { | ||
NSLog(@"error getting active energy burned samples: %@", error); | ||
callback(@[RCTMakeError(@"error getting active energy burned samples", nil, nil)]); | ||
return; | ||
} | ||
}]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters