diff --git a/RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.h b/RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.h index c683625a5c0a725d006aaedff7ece6be774bc1c3..3afd6d9f1a6c37a71b252dead5d0473782ba1a04 100644 --- a/RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.h +++ b/RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.h @@ -1,3 +1,11 @@ +// +// RCTAppleHealthKit+Methods_Sleep.h +// RCTAppleHealthKit +// +// Created by Greg Wilson on 2016-11-06. +// Copyright © 2016 Greg Wilson. All rights reserved. +// + #import "RCTAppleHealthKit.h" @interface RCTAppleHealthKit (Methods_Sleep) diff --git a/RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.m b/RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.m index 0431a67ee980238ca0ac091ed520facfd844adeb..02a7f5426bb75fc165b9d388fcb250666aab8d54 100644 --- a/RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.m +++ b/RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.m @@ -1,3 +1,10 @@ +// +// RCTAppleHealthKit+Methods_Sleep.m +// RCTAppleHealthKit +// +// Created by Greg Wilson on 2016-11-06. +// Copyright © 2016 Greg Wilson. All rights reserved. +// #import "RCTAppleHealthKit+Methods_Sleep.h" #import "RCTAppleHealthKit+Queries.h" @@ -17,78 +24,22 @@ } NSPredicate *predicate = [RCTAppleHealthKit predicateForSamplesBetweenDates:startDate endDate:endDate]; - NSUInteger *limit = [RCTAppleHealthKit uintFromOptions:input key:@"limit" withDefault:HKObjectQueryNoLimit]; + NSUInteger limit = [RCTAppleHealthKit uintFromOptions:input key:@"limit" withDefault:HKObjectQueryNoLimit]; [self fetchSleepCategorySamplesForPredicate:predicate - limit:limit - completion:^(NSArray *results, NSError *error) { - if(results){ - callback(@[[NSNull null], results]); - return; - } else { - NSLog(@"error getting sleep samples: %@", error); - callback(@[RCTMakeError(@"error getting sleep samples", nil, nil)]); - return; - } - }]; + limit:limit + completion:^(NSArray *results, NSError *error) { + if(results){ + callback(@[[NSNull null], results]); + return; + } else { + NSLog(@"error getting sleep samples: %@", error); + callback(@[RCTMakeError(@"error getting sleep samples", nil, nil)]); + return; + } + }]; - - - - - - - - - - - -// fetchSleepCategorySamplesForPredicate - - - - - // HKCategoryType *categoryType = - // [HKObjectType categoryTypeForIdentifier:HKCategoryTypeIdentifierSleepAnalysis]; - // - // HKCategorySample *categorySample = - // [HKCategorySample categorySampleWithType:categoryType - // value:HKCategoryValueSleepAnalysisAsleep - // startDate:startDate - // endDate:endDate]; - - - - - - // HKQuantityType *weightType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierBodyMass]; - // - // HKUnit *unit = [RCTAppleHealthKit hkUnitFromOptions:input]; - // if(unit == nil){ - // unit = [HKUnit poundUnit]; - // } - // - // [self fetchMostRecentQuantitySampleOfType:weightType - // predicate:nil - // completion:^(HKQuantity *mostRecentQuantity, NSDate *startDate, NSDate *endDate, NSError *error) { - // if (!mostRecentQuantity) { - // NSLog(@"error getting latest weight: %@", error); - // callback(@[RCTMakeError(@"error getting latest weight", error, nil)]); - // } - // else { - // // Determine the weight in the required unit. - // double usersWeight = [mostRecentQuantity doubleValueForUnit:unit]; - // - // NSDictionary *response = @{ - // @"value" : @(usersWeight), - // @"startDate" : [RCTAppleHealthKit buildISO8601StringFromDate:startDate], - // @"endDate" : [RCTAppleHealthKit buildISO8601StringFromDate:endDate], - // }; - // - // callback(@[[NSNull null], response]); - // } - // }]; }