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
90ada972
Commit
90ada972
authored
Nov 06, 2016
by
Greg Wilson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/sleep-analysis'
parents
ddc8b04c
c58dc3a8
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
221 additions
and
13 deletions
+221
-13
RCTAppleHealthKit.xcodeproj/project.pbxproj
RCTAppleHealthKit.xcodeproj/project.pbxproj
+6
-0
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.h
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.h
+15
-0
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.m
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.m
+46
-0
RCTAppleHealthKit/RCTAppleHealthKit+Queries.h
RCTAppleHealthKit/RCTAppleHealthKit+Queries.h
+6
-0
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
+96
-0
RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m
RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m
+4
-0
RCTAppleHealthKit/RCTAppleHealthKit.m
RCTAppleHealthKit/RCTAppleHealthKit.m
+6
-0
constants.js
constants.js
+1
-0
examples/StepsDemo/app/components/home/index.js
examples/StepsDemo/app/components/home/index.js
+26
-0
examples/StepsDemo/index.ios.js
examples/StepsDemo/index.ios.js
+2
-0
examples/StepsDemo/ios/StepsDemo.xcodeproj/project.pbxproj
examples/StepsDemo/ios/StepsDemo.xcodeproj/project.pbxproj
+12
-12
examples/StepsDemo/ios/StepsDemo/AppDelegate.m
examples/StepsDemo/ios/StepsDemo/AppDelegate.m
+1
-1
No files found.
RCTAppleHealthKit.xcodeproj/project.pbxproj
View file @
90ada972
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
3774C8D41D20C6390000B3F3
/* RCTAppleHealthKit+Methods_Body.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3774C8D31D20C6390000B3F3
/* RCTAppleHealthKit+Methods_Body.m */
;
};
3774C8D41D20C6390000B3F3
/* RCTAppleHealthKit+Methods_Body.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3774C8D31D20C6390000B3F3
/* RCTAppleHealthKit+Methods_Body.m */
;
};
3774C8D71D20C65F0000B3F3
/* RCTAppleHealthKit+Methods_Fitness.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3774C8D61D20C65F0000B3F3
/* RCTAppleHealthKit+Methods_Fitness.m */
;
};
3774C8D71D20C65F0000B3F3
/* RCTAppleHealthKit+Methods_Fitness.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
3774C8D61D20C65F0000B3F3
/* RCTAppleHealthKit+Methods_Fitness.m */
;
};
377D44F31D247D0A004E35CB
/* RCTAppleHealthKit+Methods_Characteristic.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
377D44F21D247D0A004E35CB
/* RCTAppleHealthKit+Methods_Characteristic.m */
;
};
377D44F31D247D0A004E35CB
/* RCTAppleHealthKit+Methods_Characteristic.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
377D44F21D247D0A004E35CB
/* RCTAppleHealthKit+Methods_Characteristic.m */
;
};
37837E121DCFCD0B000201A0
/* RCTAppleHealthKit+Methods_Sleep.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
37837E111DCFCD0B000201A0
/* RCTAppleHealthKit+Methods_Sleep.m */
;
};
64C42D4A1D351A8800A0A8F7
/* RCTAppleHealthKit+Methods_Vitals.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
64C42D491D351A8800A0A8F7
/* RCTAppleHealthKit+Methods_Vitals.m */
;
};
64C42D4A1D351A8800A0A8F7
/* RCTAppleHealthKit+Methods_Vitals.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
64C42D491D351A8800A0A8F7
/* RCTAppleHealthKit+Methods_Vitals.m */
;
};
64E0E73F1D37947B00EAB905
/* RCTAppleHealthKit+Methods_Results.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
64E0E73E1D37947B00EAB905
/* RCTAppleHealthKit+Methods_Results.m */
;
};
64E0E73F1D37947B00EAB905
/* RCTAppleHealthKit+Methods_Results.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
64E0E73E1D37947B00EAB905
/* RCTAppleHealthKit+Methods_Results.m */
;
};
/* End PBXBuildFile section */
/* End PBXBuildFile section */
...
@@ -48,6 +49,8 @@
...
@@ -48,6 +49,8 @@
3774C8D61D20C65F0000B3F3
/* RCTAppleHealthKit+Methods_Fitness.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
"RCTAppleHealthKit+Methods_Fitness.m"
;
sourceTree
=
"<group>"
;
};
3774C8D61D20C65F0000B3F3
/* RCTAppleHealthKit+Methods_Fitness.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
"RCTAppleHealthKit+Methods_Fitness.m"
;
sourceTree
=
"<group>"
;
};
377D44F11D247D0A004E35CB
/* RCTAppleHealthKit+Methods_Characteristic.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
"RCTAppleHealthKit+Methods_Characteristic.h"
;
sourceTree
=
"<group>"
;
};
377D44F11D247D0A004E35CB
/* RCTAppleHealthKit+Methods_Characteristic.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
"RCTAppleHealthKit+Methods_Characteristic.h"
;
sourceTree
=
"<group>"
;
};
377D44F21D247D0A004E35CB
/* RCTAppleHealthKit+Methods_Characteristic.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
"RCTAppleHealthKit+Methods_Characteristic.m"
;
sourceTree
=
"<group>"
;
};
377D44F21D247D0A004E35CB
/* RCTAppleHealthKit+Methods_Characteristic.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
"RCTAppleHealthKit+Methods_Characteristic.m"
;
sourceTree
=
"<group>"
;
};
37837E101DCFCD0B000201A0
/* RCTAppleHealthKit+Methods_Sleep.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
"RCTAppleHealthKit+Methods_Sleep.h"
;
sourceTree
=
"<group>"
;
};
37837E111DCFCD0B000201A0
/* RCTAppleHealthKit+Methods_Sleep.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
"RCTAppleHealthKit+Methods_Sleep.m"
;
sourceTree
=
"<group>"
;
};
64C42D481D351A8800A0A8F7
/* RCTAppleHealthKit+Methods_Vitals.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
"RCTAppleHealthKit+Methods_Vitals.h"
;
sourceTree
=
"<group>"
;
};
64C42D481D351A8800A0A8F7
/* RCTAppleHealthKit+Methods_Vitals.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
"RCTAppleHealthKit+Methods_Vitals.h"
;
sourceTree
=
"<group>"
;
};
64C42D491D351A8800A0A8F7
/* RCTAppleHealthKit+Methods_Vitals.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
"RCTAppleHealthKit+Methods_Vitals.m"
;
sourceTree
=
"<group>"
;
};
64C42D491D351A8800A0A8F7
/* RCTAppleHealthKit+Methods_Vitals.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
"RCTAppleHealthKit+Methods_Vitals.m"
;
sourceTree
=
"<group>"
;
};
64E0E73D1D37947B00EAB905
/* RCTAppleHealthKit+Methods_Results.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
"RCTAppleHealthKit+Methods_Results.h"
;
sourceTree
=
"<group>"
;
};
64E0E73D1D37947B00EAB905
/* RCTAppleHealthKit+Methods_Results.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
"RCTAppleHealthKit+Methods_Results.h"
;
sourceTree
=
"<group>"
;
};
...
@@ -102,6 +105,8 @@
...
@@ -102,6 +105,8 @@
3774C8D61D20C65F0000B3F3
/* RCTAppleHealthKit+Methods_Fitness.m */
,
3774C8D61D20C65F0000B3F3
/* RCTAppleHealthKit+Methods_Fitness.m */
,
377D44F11D247D0A004E35CB
/* RCTAppleHealthKit+Methods_Characteristic.h */
,
377D44F11D247D0A004E35CB
/* RCTAppleHealthKit+Methods_Characteristic.h */
,
377D44F21D247D0A004E35CB
/* RCTAppleHealthKit+Methods_Characteristic.m */
,
377D44F21D247D0A004E35CB
/* RCTAppleHealthKit+Methods_Characteristic.m */
,
37837E101DCFCD0B000201A0
/* RCTAppleHealthKit+Methods_Sleep.h */
,
37837E111DCFCD0B000201A0
/* RCTAppleHealthKit+Methods_Sleep.m */
,
);
);
path
=
RCTAppleHealthKit
;
path
=
RCTAppleHealthKit
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
...
@@ -164,6 +169,7 @@
...
@@ -164,6 +169,7 @@
files
=
(
files
=
(
3774C89B1D2095450000B3F3
/* RCTAppleHealthKit+Queries.m in Sources */
,
3774C89B1D2095450000B3F3
/* RCTAppleHealthKit+Queries.m in Sources */
,
3774C8A11D20A6B90000B3F3
/* RCTAppleHealthKit+Utils.m in Sources */
,
3774C8A11D20A6B90000B3F3
/* RCTAppleHealthKit+Utils.m in Sources */
,
37837E121DCFCD0B000201A0
/* RCTAppleHealthKit+Methods_Sleep.m in Sources */
,
3774C8D41D20C6390000B3F3
/* RCTAppleHealthKit+Methods_Body.m in Sources */
,
3774C8D41D20C6390000B3F3
/* RCTAppleHealthKit+Methods_Body.m in Sources */
,
64E0E73F1D37947B00EAB905
/* RCTAppleHealthKit+Methods_Results.m in Sources */
,
64E0E73F1D37947B00EAB905
/* RCTAppleHealthKit+Methods_Results.m in Sources */
,
64C42D4A1D351A8800A0A8F7
/* RCTAppleHealthKit+Methods_Vitals.m in Sources */
,
64C42D4A1D351A8800A0A8F7
/* RCTAppleHealthKit+Methods_Vitals.m in Sources */
,
...
...
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.h
0 → 100644
View file @
90ada972
//
// 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
)
-
(
void
)
sleep_getSleepSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
@end
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.m
0 → 100644
View file @
90ada972
//
// 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"
#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
;
}
}];
}
@end
RCTAppleHealthKit/RCTAppleHealthKit+Queries.h
View file @
90ada972
...
@@ -38,4 +38,10 @@
...
@@ -38,4 +38,10 @@
limit
:(
NSUInteger
)
lim
limit
:(
NSUInteger
)
lim
completion
:(
void
(
^
)(
NSArray
*
,
NSError
*
))
completionHandler
;
completion
:(
void
(
^
)(
NSArray
*
,
NSError
*
))
completionHandler
;
-
(
void
)
fetchSleepCategorySamplesForPredicate
:(
NSPredicate
*
)
predicate
limit
:(
NSUInteger
)
lim
completion
:(
void
(
^
)(
NSArray
*
,
NSError
*
))
completion
;
@end
@end
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
View file @
90ada972
...
@@ -106,6 +106,102 @@
...
@@ -106,6 +106,102 @@
}
}
-
(
void
)
fetchSleepCategorySamplesForPredicate
:(
NSPredicate
*
)
predicate
limit
:(
NSUInteger
)
lim
completion
:(
void
(
^
)(
NSArray
*
,
NSError
*
))
completion
{
NSSortDescriptor
*
timeSortDescriptor
=
[[
NSSortDescriptor
alloc
]
initWithKey
:
HKSampleSortIdentifierEndDate
ascending:
false
];
// declare the block
void
(
^
handlerBlock
)(
HKSampleQuery
*
query
,
NSArray
*
results
,
NSError
*
error
);
// create and assign the block
handlerBlock
=
^
(
HKSampleQuery
*
query
,
NSArray
*
results
,
NSError
*
error
)
{
if
(
!
results
)
{
if
(
completion
)
{
completion
(
nil
,
error
);
}
return
;
}
if
(
completion
)
{
NSMutableArray
*
data
=
[
NSMutableArray
arrayWithCapacity
:
1
];
dispatch_async
(
dispatch_get_main_queue
(),
^
{
for
(
HKCategorySample
*
sample
in
results
)
{
HKCategoryType
*
catType
=
sample
.
categoryType
;
NSInteger
val
=
sample
.
value
;
// HKQuantity *quantity = sample.quantity;
// double value = [quantity doubleValueForUnit:unit];
NSString
*
startDateString
=
[
RCTAppleHealthKit
buildISO8601StringFromDate
:
sample
.
startDate
];
NSString
*
endDateString
=
[
RCTAppleHealthKit
buildISO8601StringFromDate
:
sample
.
endDate
];
NSDictionary
*
elem
=
@{
@"value"
:
@
((
(
float
)
val
)),
@"catType"
:
catType
.
identifier
,
@"startDate"
:
startDateString
,
@"endDate"
:
endDateString
,
};
[
data
addObject
:
elem
];
}
completion
(
data
,
error
);
});
}
};
// HKSampleQuery *query = [[HKSampleQuery alloc] initWithSampleType:quantityType
// predicate:predicate
// limit:lim
// sortDescriptors:@[timeSortDescriptor]
// resultsHandler:handlerBlock];
HKCategoryType
*
categoryType
=
[
HKObjectType
categoryTypeForIdentifier
:
HKCategoryTypeIdentifierSleepAnalysis
];
// HKCategorySample *categorySample =
// [HKCategorySample categorySampleWithType:categoryType
// value:value
// startDate:startDate
// endDate:endDate];
HKSampleQuery
*
query
=
[[
HKSampleQuery
alloc
]
initWithSampleType
:
categoryType
predicate:
predicate
limit:
lim
sortDescriptors:
@[
timeSortDescriptor
]
resultsHandler:
handlerBlock
];
[
self
.
healthStore
executeQuery
:
query
];
}
-
(
void
)
fetchCorrelationSamplesOfType
:(
HKQuantityType
*
)
quantityType
-
(
void
)
fetchCorrelationSamplesOfType
:(
HKQuantityType
*
)
quantityType
unit
:(
HKUnit
*
)
unit
unit
:(
HKUnit
*
)
unit
predicate
:(
NSPredicate
*
)
predicate
predicate
:(
NSPredicate
*
)
predicate
...
...
RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m
View file @
90ada972
...
@@ -45,6 +45,8 @@
...
@@ -45,6 +45,8 @@
@"RespiratoryRate"
:
[
HKObjectType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierRespiratoryRate
],
@"RespiratoryRate"
:
[
HKObjectType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierRespiratoryRate
],
// Results Identifiers
// Results Identifiers
@"BloodGlucose"
:
[
HKObjectType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierBloodGlucose
],
@"BloodGlucose"
:
[
HKObjectType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierBloodGlucose
],
// Sleep
@"SleepAnalysis"
:
[
HKObjectType
categoryTypeForIdentifier
:
HKCategoryTypeIdentifierSleepAnalysis
],
};
};
return
readPerms
;
return
readPerms
;
}
}
...
@@ -69,6 +71,8 @@
...
@@ -69,6 +71,8 @@
@"FlightsClimbed"
:
[
HKObjectType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierFlightsClimbed
],
@"FlightsClimbed"
:
[
HKObjectType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierFlightsClimbed
],
// Nutrition Identifiers
// Nutrition Identifiers
@"DietaryEnergy"
:
[
HKObjectType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierDietaryEnergyConsumed
],
@"DietaryEnergy"
:
[
HKObjectType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierDietaryEnergyConsumed
],
// Sleep
@"SleepAnalysis"
:
[
HKObjectType
categoryTypeForIdentifier
:
HKCategoryTypeIdentifierSleepAnalysis
],
};
};
return
writePerms
;
return
writePerms
;
}
}
...
...
RCTAppleHealthKit/RCTAppleHealthKit.m
View file @
90ada972
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
#import "RCTAppleHealthKit+Methods_Characteristic.h"
#import "RCTAppleHealthKit+Methods_Characteristic.h"
#import "RCTAppleHealthKit+Methods_Vitals.h"
#import "RCTAppleHealthKit+Methods_Vitals.h"
#import "RCTAppleHealthKit+Methods_Results.h"
#import "RCTAppleHealthKit+Methods_Results.h"
#import "RCTAppleHealthKit+Methods_Sleep.h"
#import "RCTBridge.h"
#import "RCTBridge.h"
#import "RCTEventDispatcher.h"
#import "RCTEventDispatcher.h"
...
@@ -153,6 +154,11 @@ RCT_EXPORT_METHOD(getBloodGlucoseSamples:(NSDictionary *)input callback:(RCTResp
...
@@ -153,6 +154,11 @@ RCT_EXPORT_METHOD(getBloodGlucoseSamples:(NSDictionary *)input callback:(RCTResp
[
self
results_getBloodGlucoseSamples
:
input
callback
:
callback
];
[
self
results_getBloodGlucoseSamples
:
input
callback
:
callback
];
}
}
RCT_EXPORT_METHOD
(
getSleepSamples
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
{
[
self
sleep_getSleepSamples
:
input
callback
:
callback
];
}
RCT_EXPORT_METHOD
(
getInfo
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
RCT_EXPORT_METHOD
(
getInfo
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
{
{
[
self
getModuleInfo
:
input
callback
:
callback
];
[
self
getModuleInfo
:
input
callback
:
callback
];
...
...
constants.js
View file @
90ada972
...
@@ -25,6 +25,7 @@ const PERMISSIONS = {
...
@@ -25,6 +25,7 @@ const PERMISSIONS = {
BloodPressureDiastolic
:
'
BloodPressureDiastolic
'
,
BloodPressureDiastolic
:
'
BloodPressureDiastolic
'
,
RespiratoryRate
:
'
RespiratoryRate
'
,
RespiratoryRate
:
'
RespiratoryRate
'
,
BloodGlucose
:
'
BloodGlucose
'
,
BloodGlucose
:
'
BloodGlucose
'
,
SleepAnalysis
:
'
SleepAnalysis
'
,
};
};
...
...
examples/StepsDemo/app/components/home/index.js
View file @
90ada972
...
@@ -28,6 +28,7 @@ const HKOPTIONS = {
...
@@ -28,6 +28,7 @@ const HKOPTIONS = {
HKPERMS
.
Height
,
HKPERMS
.
Height
,
HKPERMS
.
DateOfBirth
,
HKPERMS
.
DateOfBirth
,
HKPERMS
.
BiologicalSex
,
HKPERMS
.
BiologicalSex
,
HKPERMS
.
SleepAnalysis
,
],
],
write
:
[
write
:
[
HKPERMS
.
StepCount
HKPERMS
.
StepCount
...
@@ -75,6 +76,8 @@ class Home extends Component {
...
@@ -75,6 +76,8 @@ class Home extends Component {
this
.
_fetchStepsToday
();
this
.
_fetchStepsToday
();
this
.
_fetchStepsHistory
();
this
.
_fetchStepsHistory
();
this
.
_fetchSleepAnalysis
();
});
});
}
}
});
});
...
@@ -115,6 +118,29 @@ class Home extends Component {
...
@@ -115,6 +118,29 @@ class Home extends Component {
});
});
}
}
_fetchSleepAnalysis
()
{
let
options
=
{
startDate
:
(
new
Date
(
2016
,
10
,
1
)).
toISOString
(),
};
AppleHealthKit
.
getSleepSamples
(
options
,
(
err
,
res
)
=>
{
if
(
this
.
_handleHKError
(
err
,
'
getSleepSamples
'
)){
return
;
}
//this.setState({stepHistory: res});
console
.
log
(
'
######################################
'
)
console
.
log
(
'
### SLEEP SAMPLES ###
'
)
console
.
log
(
'
######################################
'
)
console
.
log
(
res
)
});
}
/**
/**
* render the Navigator which will render the navigation
* render the Navigator which will render the navigation
* bar and the scene
* bar and the scene
...
...
examples/StepsDemo/index.ios.js
View file @
90ada972
...
@@ -12,6 +12,8 @@ import {
...
@@ -12,6 +12,8 @@ import {
View
View
}
from
'
react-native
'
;
}
from
'
react-native
'
;
require
(
'
RCTNativeAppEventEmitter
'
)
import
App
from
'
./app/app
'
;
import
App
from
'
./app/app
'
;
class
StepsDemo
extends
Component
{
class
StepsDemo
extends
Component
{
...
...
examples/StepsDemo/ios/StepsDemo.xcodeproj/project.pbxproj
View file @
90ada972
...
@@ -22,7 +22,6 @@
...
@@ -22,7 +22,6 @@
13B07FC11A68108700A75B9A
/* main.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
13B07FB71A68108700A75B9A
/* main.m */
;
};
13B07FC11A68108700A75B9A
/* main.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
13B07FB71A68108700A75B9A
/* main.m */
;
};
140ED2AC1D01E1AD002B40FF
/* libReact.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
146834041AC3E56700842450
/* libReact.a */
;
};
140ED2AC1D01E1AD002B40FF
/* libReact.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
146834041AC3E56700842450
/* libReact.a */
;
};
146834051AC3E58100842450
/* libReact.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
146834041AC3E56700842450
/* libReact.a */
;
};
146834051AC3E58100842450
/* libReact.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
146834041AC3E56700842450
/* libReact.a */
;
};
377F68B31D7A0D9C00B64DB1
/* libRCTAppleHealthKit.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
377F68B21D7A0D9800B64DB1
/* libRCTAppleHealthKit.a */
;
};
378616B61D257B040027C300
/* HealthKit.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
378616B51D257B040027C300
/* HealthKit.framework */
;
};
378616B61D257B040027C300
/* HealthKit.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
378616B51D257B040027C300
/* HealthKit.framework */
;
};
832341BD1AAA6AB300B99B32
/* libRCTText.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
832341B51AAA6A8300B99B32
/* libRCTText.a */
;
};
832341BD1AAA6AB300B99B32
/* libRCTText.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
832341B51AAA6A8300B99B32
/* libRCTText.a */
;
};
/* End PBXBuildFile section */
/* End PBXBuildFile section */
...
@@ -91,9 +90,9 @@
...
@@ -91,9 +90,9 @@
remoteGlobalIDString
=
83CBBA2E1A601D0E00E9B192
;
remoteGlobalIDString
=
83CBBA2E1A601D0E00E9B192
;
remoteInfo
=
React
;
remoteInfo
=
React
;
};
};
37
7F68B11D7A0D9800B64DB1
/* PBXContainerItemProxy */
=
{
37
837E301DCFDBCA000201A0
/* PBXContainerItemProxy */
=
{
isa
=
PBXContainerItemProxy
;
isa
=
PBXContainerItemProxy
;
containerPortal
=
37
7F68AD1D7A0D9800B64DB1
/* RCTAppleHealthKit.xcodeproj */
;
containerPortal
=
37
837E2C1DCFDBCA000201A0
/* RCTAppleHealthKit.xcodeproj */
;
proxyType
=
2
;
proxyType
=
2
;
remoteGlobalIDString
=
3774C88D1D2092F20000B3F3
;
remoteGlobalIDString
=
3774C88D1D2092F20000B3F3
;
remoteInfo
=
RCTAppleHealthKit
;
remoteInfo
=
RCTAppleHealthKit
;
...
@@ -134,7 +133,7 @@
...
@@ -134,7 +133,7 @@
13B07FB61A68108700A75B9A
/* Info.plist */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
text.plist.xml
;
name
=
Info.plist
;
path
=
StepsDemo/Info.plist
;
sourceTree
=
"<group>"
;
};
13B07FB61A68108700A75B9A
/* Info.plist */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
text.plist.xml
;
name
=
Info.plist
;
path
=
StepsDemo/Info.plist
;
sourceTree
=
"<group>"
;
};
13B07FB71A68108700A75B9A
/* main.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
name
=
main.m
;
path
=
StepsDemo/main.m
;
sourceTree
=
"<group>"
;
};
13B07FB71A68108700A75B9A
/* main.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
name
=
main.m
;
path
=
StepsDemo/main.m
;
sourceTree
=
"<group>"
;
};
146833FF1AC3E56700842450
/* React.xcodeproj */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"wrapper.pb-project"
;
name
=
React.xcodeproj
;
path
=
"../node_modules/react-native/React/React.xcodeproj"
;
sourceTree
=
"<group>"
;
};
146833FF1AC3E56700842450
/* React.xcodeproj */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"wrapper.pb-project"
;
name
=
React.xcodeproj
;
path
=
"../node_modules/react-native/React/React.xcodeproj"
;
sourceTree
=
"<group>"
;
};
37
7F68AD1D7A0D9800B64DB1
/* RCTAppleHealthKit.xcodeproj */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"wrapper.pb-project"
;
name
=
RCTAppleHealthKit.xcodeproj
;
path
=
"../node_modules/react-native-apple-healthkit/RCTAppleHealthKit.xcodeproj"
;
sourceTree
=
"<group>"
;
};
37
837E2C1DCFDBCA000201A0
/* RCTAppleHealthKit.xcodeproj */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"wrapper.pb-project"
;
name
=
RCTAppleHealthKit.xcodeproj
;
path
=
"../node_modules/react-native-apple-healthkit/RCTAppleHealthKit.xcodeproj"
;
sourceTree
=
"<group>"
;
};
378616B51D257B040027C300
/* HealthKit.framework */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
wrapper.framework
;
name
=
HealthKit.framework
;
path
=
System/Library/Frameworks/HealthKit.framework
;
sourceTree
=
SDKROOT
;
};
378616B51D257B040027C300
/* HealthKit.framework */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
wrapper.framework
;
name
=
HealthKit.framework
;
path
=
System/Library/Frameworks/HealthKit.framework
;
sourceTree
=
SDKROOT
;
};
378616B71D257B040027C300
/* StepsDemo.entitlements */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
text.xml
;
name
=
StepsDemo.entitlements
;
path
=
StepsDemo/StepsDemo.entitlements
;
sourceTree
=
"<group>"
;
};
378616B71D257B040027C300
/* StepsDemo.entitlements */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
text.xml
;
name
=
StepsDemo.entitlements
;
path
=
StepsDemo/StepsDemo.entitlements
;
sourceTree
=
"<group>"
;
};
78C398B01ACF4ADC00677621
/* RCTLinking.xcodeproj */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"wrapper.pb-project"
;
name
=
RCTLinking.xcodeproj
;
path
=
"../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"
;
sourceTree
=
"<group>"
;
};
78C398B01ACF4ADC00677621
/* RCTLinking.xcodeproj */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"wrapper.pb-project"
;
name
=
RCTLinking.xcodeproj
;
path
=
"../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"
;
sourceTree
=
"<group>"
;
};
...
@@ -154,7 +153,6 @@
...
@@ -154,7 +153,6 @@
isa
=
PBXFrameworksBuildPhase
;
isa
=
PBXFrameworksBuildPhase
;
buildActionMask
=
2147483647
;
buildActionMask
=
2147483647
;
files
=
(
files
=
(
377F68B31D7A0D9C00B64DB1
/* libRCTAppleHealthKit.a in Frameworks */
,
139FDEF61B0652A700C62182
/* libRCTWebSocket.a in Frameworks */
,
139FDEF61B0652A700C62182
/* libRCTWebSocket.a in Frameworks */
,
146834051AC3E58100842450
/* libReact.a in Frameworks */
,
146834051AC3E58100842450
/* libReact.a in Frameworks */
,
00C302E51ABCBA2D00DB3ED1
/* libRCTActionSheet.a in Frameworks */
,
00C302E51ABCBA2D00DB3ED1
/* libRCTActionSheet.a in Frameworks */
,
...
@@ -268,10 +266,10 @@
...
@@ -268,10 +266,10 @@
name
=
Products
;
name
=
Products
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
};
};
37
7F68AE1D7A0D9800B64DB1
/* Products */
=
{
37
837E2D1DCFDBCA000201A0
/* Products */
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
37
7F68B21D7A0D9800B64DB1
/* libRCTAppleHealthKit.a */
,
37
837E311DCFDBCA000201A0
/* libRCTAppleHealthKit.a */
,
);
);
name
=
Products
;
name
=
Products
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
...
@@ -287,7 +285,7 @@
...
@@ -287,7 +285,7 @@
832341AE1AAA6A7D00B99B32
/* Libraries */
=
{
832341AE1AAA6A7D00B99B32
/* Libraries */
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
37
7F68AD1D7A0D9800B64DB1
/* RCTAppleHealthKit.xcodeproj */
,
37
837E2C1DCFDBCA000201A0
/* RCTAppleHealthKit.xcodeproj */
,
146833FF1AC3E56700842450
/* React.xcodeproj */
,
146833FF1AC3E56700842450
/* React.xcodeproj */
,
00C302A71ABCB8CE00DB3ED1
/* RCTActionSheet.xcodeproj */
,
00C302A71ABCB8CE00DB3ED1
/* RCTActionSheet.xcodeproj */
,
00C302B51ABCB90400DB3ED1
/* RCTGeolocation.xcodeproj */
,
00C302B51ABCB90400DB3ED1
/* RCTGeolocation.xcodeproj */
,
...
@@ -411,8 +409,8 @@
...
@@ -411,8 +409,8 @@
ProjectRef
=
00C302A71ABCB8CE00DB3ED1
/* RCTActionSheet.xcodeproj */
;
ProjectRef
=
00C302A71ABCB8CE00DB3ED1
/* RCTActionSheet.xcodeproj */
;
},
},
{
{
ProductGroup
=
37
7F68AE1D7A0D9800B64DB1
/* Products */
;
ProductGroup
=
37
837E2D1DCFDBCA000201A0
/* Products */
;
ProjectRef
=
37
7F68AD1D7A0D9800B64DB1
/* RCTAppleHealthKit.xcodeproj */
;
ProjectRef
=
37
837E2C1DCFDBCA000201A0
/* RCTAppleHealthKit.xcodeproj */
;
},
},
{
{
ProductGroup
=
00C302B61ABCB90400DB3ED1
/* Products */
;
ProductGroup
=
00C302B61ABCB90400DB3ED1
/* Products */
;
...
@@ -516,11 +514,11 @@
...
@@ -516,11 +514,11 @@
remoteRef
=
146834031AC3E56700842450
/* PBXContainerItemProxy */
;
remoteRef
=
146834031AC3E56700842450
/* PBXContainerItemProxy */
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
};
37
7F68B21D7A0D9800B64DB1
/* libRCTAppleHealthKit.a */
=
{
37
837E311DCFDBCA000201A0
/* libRCTAppleHealthKit.a */
=
{
isa
=
PBXReferenceProxy
;
isa
=
PBXReferenceProxy
;
fileType
=
archive.ar
;
fileType
=
archive.ar
;
path
=
libRCTAppleHealthKit.a
;
path
=
libRCTAppleHealthKit.a
;
remoteRef
=
37
7F68B11D7A0D9800B64DB1
/* PBXContainerItemProxy */
;
remoteRef
=
37
837E301DCFDBCA000201A0
/* PBXContainerItemProxy */
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
};
78C398B91ACF4ADC00677621
/* libRCTLinking.a */
=
{
78C398B91ACF4ADC00677621
/* libRCTLinking.a */
=
{
...
@@ -734,6 +732,7 @@
...
@@ -734,6 +732,7 @@
IPHONEOS_DEPLOYMENT_TARGET
=
7.0
;
IPHONEOS_DEPLOYMENT_TARGET
=
7.0
;
MTL_ENABLE_DEBUG_INFO
=
YES
;
MTL_ENABLE_DEBUG_INFO
=
YES
;
ONLY_ACTIVE_ARCH
=
YES
;
ONLY_ACTIVE_ARCH
=
YES
;
OTHER_LDFLAGS
=
""
;
SDKROOT
=
iphoneos
;
SDKROOT
=
iphoneos
;
};
};
name
=
Debug
;
name
=
Debug
;
...
@@ -773,6 +772,7 @@
...
@@ -773,6 +772,7 @@
);
);
IPHONEOS_DEPLOYMENT_TARGET
=
7.0
;
IPHONEOS_DEPLOYMENT_TARGET
=
7.0
;
MTL_ENABLE_DEBUG_INFO
=
NO
;
MTL_ENABLE_DEBUG_INFO
=
NO
;
OTHER_LDFLAGS
=
""
;
SDKROOT
=
iphoneos
;
SDKROOT
=
iphoneos
;
VALIDATE_PRODUCT
=
YES
;
VALIDATE_PRODUCT
=
YES
;
};
};
...
...
examples/StepsDemo/ios/StepsDemo/AppDelegate.m
View file @
90ada972
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
* on the same Wi-Fi network.
* on the same Wi-Fi network.
*/
*/
//
//
jsCodeLocation
=
[
NSURL
URLWithString
:
@"http://192.168.0.1
3
:8081/index.ios.bundle?platform=ios&dev=true"
];
jsCodeLocation
=
[
NSURL
URLWithString
:
@"http://192.168.0.1
2
:8081/index.ios.bundle?platform=ios&dev=true"
];
// jsCodeLocation = [NSURL URLWithString:@"http://10.1.14.163:8081/index.ios.bundle?platform=ios&dev=true"];
// jsCodeLocation = [NSURL URLWithString:@"http://10.1.14.163:8081/index.ios.bundle?platform=ios&dev=true"];
/**
/**
* OPTION 2
* OPTION 2
...
...
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