Commit ebdf34f8 authored by Greg Wilson's avatar Greg Wilson

added fitness_getDailyStepCounts method

parent 5f75fab5
...@@ -13,4 +13,6 @@ ...@@ -13,4 +13,6 @@
- (void)fitness_getStepCountForToday:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback; - (void)fitness_getStepCountForToday:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
- (void)fitness_getStepCountForDay:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback; - (void)fitness_getStepCountForDay:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
- (void)fitness_getDailyStepCounts:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback;
@end @end
...@@ -51,4 +51,31 @@ ...@@ -51,4 +51,31 @@
} }
- (void)fitness_getDailyStepCounts:(NSDictionary *)input callback:(RCTResponseSenderBlock)callback
{
NSDate *startDate = [RCTAppleHealthKit startDateFromOptions:input];
NSDate *endDate = [RCTAppleHealthKit endDateFromOptionsDefaultNow:input];
if(startDate == nil) {
callback(@[RCTMakeError(@"could not parse required startDate from options.startDate", nil, nil)]);
return;
}
HKQuantityType *stepCountType = [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierStepCount];
HKUnit *stepsUnit = [HKUnit countUnit];
[self fetchCumulativeSumStatisticsCollection:stepCountType unit:stepsUnit startDate:startDate endDate:endDate 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
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