Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rn-apple-healthkit
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ym
rn-apple-healthkit
Commits
ea7b0437
Commit
ea7b0437
authored
Nov 06, 2016
by
Greg Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added new Methods_Sleep category
parent
ddc8b04c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
0 deletions
+102
-0
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.h
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.h
+7
-0
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.m
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.m
+95
-0
No files found.
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.h
0 → 100644
View file @
ea7b0437
#import "RCTAppleHealthKit.h"
@interface
RCTAppleHealthKit
(
Methods_Sleep
)
-
(
void
)
sleep_getSleepSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
@end
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.m
0 → 100644
View file @
ea7b0437
#import "RCTAppleHealthKit+Methods_Sleep.h"
#import "RCTAppleHealthKit+Queries.h"
#import "RCTAppleHealthKit+Utils.h"
@implementation
RCTAppleHealthKit
(
Methods_Sleep
)
-
(
void
)
sleep_getSleepSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
{
NSDate
*
startDate
=
[
RCTAppleHealthKit
dateFromOptions
:
input
key
:
@"startDate"
withDefault
:
nil
];
NSDate
*
endDate
=
[
RCTAppleHealthKit
dateFromOptions
:
input
key
:
@"endDate"
withDefault
:
[
NSDate
date
]];
if
(
startDate
==
nil
){
callback
(@[
RCTMakeError
(
@"startDate is required in options"
,
nil
,
nil
)]);
return
;
}
NSPredicate
*
predicate
=
[
RCTAppleHealthKit
predicateForSamplesBetweenDates
:
startDate
endDate
:
endDate
];
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
;
}
}];
// 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]);
// }
// }];
}
@end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment