Commit bfb4b3c5 authored by Greg Wilson's avatar Greg Wilson

added methods to Methods_Sleep category

parent 51f8a6ed
//
// RCTAppleHealthKit+Methods_Sleep.h
// RCTAppleHealthKit
//
// Created by Greg Wilson on 2016-11-06.
// Copyright © 2016 Greg Wilson. All rights reserved.
//
#import "RCTAppleHealthKit.h" #import "RCTAppleHealthKit.h"
@interface RCTAppleHealthKit (Methods_Sleep) @interface RCTAppleHealthKit (Methods_Sleep)
......
//
// 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+Methods_Sleep.h"
#import "RCTAppleHealthKit+Queries.h" #import "RCTAppleHealthKit+Queries.h"
...@@ -17,78 +24,22 @@ ...@@ -17,78 +24,22 @@
} }
NSPredicate *predicate = [RCTAppleHealthKit predicateForSamplesBetweenDates:startDate endDate:endDate]; 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 [self fetchSleepCategorySamplesForPredicate:predicate
limit:limit limit:limit
completion:^(NSArray *results, NSError *error) { completion:^(NSArray *results, NSError *error) {
if(results){ if(results){
callback(@[[NSNull null], results]); callback(@[[NSNull null], results]);
return; return;
} else { } else {
NSLog(@"error getting sleep samples: %@", error); NSLog(@"error getting sleep samples: %@", error);
callback(@[RCTMakeError(@"error getting sleep samples", nil, nil)]); callback(@[RCTMakeError(@"error getting sleep samples", nil, nil)]);
return; 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]);
// }
// }];
} }
......
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