Commit 67679c39 authored by Furyou81's avatar Furyou81

adding a flag includeManuallyAdded

parent ad2e4eac
...@@ -104,6 +104,8 @@ ...@@ -104,6 +104,8 @@
NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil]; NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil];
NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]]; NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]];
NSUInteger period = [RCTAppleHealthKit uintFromOptions:input key:@"period" withDefault:60]; NSUInteger period = [RCTAppleHealthKit uintFromOptions:input key:@"period" withDefault:60];
BOOL includeManuallyAdded = [RCTAppleHealthKit boolFromOptions:input key:@"includeManuallyAdded" withDefault:false];
if(startDate == nil){ if(startDate == nil){
callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]); callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]);
return; return;
...@@ -118,6 +120,7 @@ ...@@ -118,6 +120,7 @@
endDate:endDate endDate:endDate
ascending:ascending ascending:ascending
limit:limit limit:limit
includeManuallyAdded:includeManuallyAdded
completion:^(NSArray *arr, NSError *err){ completion:^(NSArray *arr, NSError *err){
if (err != nil) { if (err != nil) {
NSLog(@"error with fetchCumulativeSumStatisticsCollection: %@", err); NSLog(@"error with fetchCumulativeSumStatisticsCollection: %@", err);
...@@ -221,6 +224,7 @@ ...@@ -221,6 +224,7 @@
NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil]; NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil];
NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]]; NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]];
NSUInteger period = [RCTAppleHealthKit uintFromOptions:input key:@"period" withDefault:60]; NSUInteger period = [RCTAppleHealthKit uintFromOptions:input key:@"period" withDefault:60];
BOOL includeManuallyAdded = [RCTAppleHealthKit boolFromOptions:input key:@"includeManuallyAdded" withDefault:false];
if(startDate == nil){ if(startDate == nil){
callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]); callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]);
return; return;
...@@ -235,6 +239,7 @@ ...@@ -235,6 +239,7 @@
endDate:endDate endDate:endDate
ascending:ascending ascending:ascending
limit:limit limit:limit
includeManuallyAdded:includeManuallyAdded
completion:^(NSArray *arr, NSError *err){ completion:^(NSArray *arr, NSError *err){
if (err != nil) { if (err != nil) {
NSLog(@"error with fetchCumulativeSumStatisticsCollection: %@", err); NSLog(@"error with fetchCumulativeSumStatisticsCollection: %@", err);
...@@ -253,6 +258,7 @@ ...@@ -253,6 +258,7 @@
NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil]; NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil];
NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]]; NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]];
NSUInteger period = [RCTAppleHealthKit uintFromOptions:input key:@"period" withDefault:60]; NSUInteger period = [RCTAppleHealthKit uintFromOptions:input key:@"period" withDefault:60];
BOOL includeManuallyAdded = [RCTAppleHealthKit boolFromOptions:input key:@"includeManuallyAdded" withDefault:false];
if(startDate == nil){ if(startDate == nil){
callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]); callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]);
return; return;
...@@ -267,6 +273,7 @@ ...@@ -267,6 +273,7 @@
endDate:endDate endDate:endDate
ascending:ascending ascending:ascending
limit:limit limit:limit
includeManuallyAdded:includeManuallyAdded
completion:^(NSArray *arr, NSError *err){ completion:^(NSArray *arr, NSError *err){
if (err != nil) { if (err != nil) {
NSLog(@"error with fetchCumulativeSumStatisticsCollection: %@", err); NSLog(@"error with fetchCumulativeSumStatisticsCollection: %@", err);
...@@ -309,6 +316,7 @@ ...@@ -309,6 +316,7 @@
NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil]; NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil];
NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]]; NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]];
NSUInteger period = [RCTAppleHealthKit uintFromOptions:input key:@"period" withDefault:60]; NSUInteger period = [RCTAppleHealthKit uintFromOptions:input key:@"period" withDefault:60];
BOOL includeManuallyAdded = [RCTAppleHealthKit boolFromOptions:input key:@"includeManuallyAdded" withDefault:false];
if(startDate == nil){ if(startDate == nil){
callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]); callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]);
return; return;
...@@ -323,6 +331,7 @@ ...@@ -323,6 +331,7 @@
endDate:endDate endDate:endDate
ascending:ascending ascending:ascending
limit:limit limit:limit
includeManuallyAdded:includeManuallyAdded
completion:^(NSArray *arr, NSError *err){ completion:^(NSArray *arr, NSError *err){
if (err != nil) { if (err != nil) {
NSLog(@"error with fetchCumulativeSumStatisticsCollection: %@", err); NSLog(@"error with fetchCumulativeSumStatisticsCollection: %@", err);
......
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
endDate:(NSDate *)endDate endDate:(NSDate *)endDate
ascending:(BOOL)asc ascending:(BOOL)asc
limit:(NSUInteger)lim limit:(NSUInteger)lim
includeManuallyAdded:(BOOL)includeManuallyAdded
completion:(void (^)(NSArray *, NSError *))completionHandler; completion:(void (^)(NSArray *, NSError *))completionHandler;
......
...@@ -578,6 +578,7 @@ ...@@ -578,6 +578,7 @@
endDate:(NSDate *)endDate endDate:(NSDate *)endDate
ascending:(BOOL)asc ascending:(BOOL)asc
limit:(NSUInteger)lim limit:(NSUInteger)lim
includeManuallyAdded:(BOOL)includeManuallyAdded
completion:(void (^)(NSArray *, NSError *))completionHandler { completion:(void (^)(NSArray *, NSError *))completionHandler {
NSCalendar *calendar = [NSCalendar currentCalendar]; NSCalendar *calendar = [NSCalendar currentCalendar];
...@@ -588,7 +589,10 @@ ...@@ -588,7 +589,10 @@
fromDate:startDate]; fromDate:startDate];
//anchorComponents.hour = 0; //anchorComponents.hour = 0;
NSDate *anchorDate = [calendar dateFromComponents:anchorComponents]; NSDate *anchorDate = [calendar dateFromComponents:anchorComponents];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"metadata.%K != YES", HKMetadataKeyWasUserEntered]; NSPredicate *predicate = nil;
if (includeManuallyAdded == false) {
predicate = [NSPredicate predicateWithFormat:@"metadata.%K != YES", HKMetadataKeyWasUserEntered];
}
// Create the query // Create the query
HKStatisticsCollectionQuery *query = [[HKStatisticsCollectionQuery alloc] initWithQuantityType:quantityType HKStatisticsCollectionQuery *query = [[HKStatisticsCollectionQuery alloc] initWithQuantityType:quantityType
quantitySamplePredicate:predicate quantitySamplePredicate:predicate
......
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