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
4d738c38
Commit
4d738c38
authored
Nov 06, 2016
by
Greg Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated code and added documentation for getSleepSamples
parent
54acd3c1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
6 deletions
+87
-6
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
+16
-3
README.md
README.md
+40
-1
examples/StepsDemo/ios/StepsDemo.xcodeproj/project.pbxproj
examples/StepsDemo/ios/StepsDemo.xcodeproj/project.pbxproj
+30
-0
examples/StepsDemo/package.json
examples/StepsDemo/package.json
+1
-2
No files found.
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
View file @
4d738c38
...
@@ -140,7 +140,7 @@
...
@@ -140,7 +140,7 @@
for
(
HKCategorySample
*
sample
in
results
)
{
for
(
HKCategorySample
*
sample
in
results
)
{
HKCategoryType
*
catType
=
sample
.
categoryType
;
//
HKCategoryType *catType = sample.categoryType;
NSInteger
val
=
sample
.
value
;
NSInteger
val
=
sample
.
value
;
// HKQuantity *quantity = sample.quantity;
// HKQuantity *quantity = sample.quantity;
...
@@ -149,9 +149,22 @@
...
@@ -149,9 +149,22 @@
NSString
*
startDateString
=
[
RCTAppleHealthKit
buildISO8601StringFromDate
:
sample
.
startDate
];
NSString
*
startDateString
=
[
RCTAppleHealthKit
buildISO8601StringFromDate
:
sample
.
startDate
];
NSString
*
endDateString
=
[
RCTAppleHealthKit
buildISO8601StringFromDate
:
sample
.
endDate
];
NSString
*
endDateString
=
[
RCTAppleHealthKit
buildISO8601StringFromDate
:
sample
.
endDate
];
NSString
*
valueString
;
switch
(
val
)
{
case
HKCategoryValueSleepAnalysisInBed
:
valueString
=
@"INBED"
;
break
;
case
HKCategoryValueSleepAnalysisAsleep
:
valueString
=
@"ASLEEP"
;
break
;
default:
valueString
=
@"UNKNOWN"
;
break
;
}
NSDictionary
*
elem
=
@{
NSDictionary
*
elem
=
@{
@"value"
:
@
((
(
float
)
val
)),
@"value"
:
valueString
,
@"catType"
:
catType
.
identifier
,
@"startDate"
:
startDateString
,
@"startDate"
:
startDateString
,
@"endDate"
:
endDateString
,
@"endDate"
:
endDateString
,
};
};
...
...
README.md
View file @
4d738c38
...
@@ -41,6 +41,7 @@ A React Native bridge module for interacting with [Apple HealthKit] data.
...
@@ -41,6 +41,7 @@ A React Native bridge module for interacting with [Apple HealthKit] data.
*
[
getBloodPressureSamples
](
#getbloodpressuresamples
)
*
[
getBloodPressureSamples
](
#getbloodpressuresamples
)
*
[
getRespiratoryRateSamples
](
#getrespiratoryratesamples
)
*
[
getRespiratoryRateSamples
](
#getrespiratoryratesamples
)
*
[
getBloodGlucoseSamples
](
#getbloodglucosesamples
)
*
[
getBloodGlucoseSamples
](
#getbloodglucosesamples
)
*
[
getSleepSamples
](
#getsleepsamples
)
*
[
Examples
](
#examples
)
*
[
Examples
](
#examples
)
...
@@ -151,7 +152,10 @@ The available HealthKit permissions to use with `initHealthKit`
...
@@ -151,7 +152,10 @@ The available HealthKit permissions to use with `initHealthKit`
| BloodPressureSystolic |
[
HKQuantityTypeIdentifierBloodPressureSystolic
](
https://developer.apple.com/reference/healthkit/hkquantitytypeidentifierbloodpressuresystolic?language=objc
)
| ✓ | |
| BloodPressureSystolic |
[
HKQuantityTypeIdentifierBloodPressureSystolic
](
https://developer.apple.com/reference/healthkit/hkquantitytypeidentifierbloodpressuresystolic?language=objc
)
| ✓ | |
| BloodPressureDiastolic |
[
HKQuantityTypeIdentifierBloodPressureDiastolic
](
https://developer.apple.com/reference/healthkit/hkquantitytypeidentifierbloodpressurediastolic?language=objc
)
| ✓ | |
| BloodPressureDiastolic |
[
HKQuantityTypeIdentifierBloodPressureDiastolic
](
https://developer.apple.com/reference/healthkit/hkquantitytypeidentifierbloodpressurediastolic?language=objc
)
| ✓ | |
| RespiratoryRate |
[
HKQuantityTypeIdentifierRespiratoryRate
](
https://developer.apple.com/reference/healthkit/hkquantitytypeidentifierrespiratoryrate?language=objc
)
| ✓ | |
| RespiratoryRate |
[
HKQuantityTypeIdentifierRespiratoryRate
](
https://developer.apple.com/reference/healthkit/hkquantitytypeidentifierrespiratoryrate?language=objc
)
| ✓ | |
| BloodGlucose |
[
HKQuantityTypeIdentifierBloodGlucose
](
https://developer.apple.com/reference/healthkit/hkquantitytypeidentifierbloodglucose?language=objc
)
| ✓ | |
| BloodGlucose |
[
HKQuantityTypeIdentifierBloodGlucose
](
https://developer.apple.com/reference/healthkit/hkquantitytypeidentifierbloodglucose?language=objc
)
| ✓ |
|
| SleepAnalysis |
[
HKCategoryTypeIdentifierSleepAnalysis
](
https://developer.apple.com/reference/healthkit/hkcategorytypeidentifiersleepanalysis?language=objc
)
| ✓ |
|
These permissions are exported as constants of the
`react-native-apple-healthkit`
module.
These permissions are exported as constants of the
`react-native-apple-healthkit`
module.
...
@@ -873,6 +877,40 @@ AppleHealthKit.getBloodGlucoseSamples(options, (err: Object, samples: Array<Obje
...
@@ -873,6 +877,40 @@ AppleHealthKit.getBloodGlucoseSamples(options, (err: Object, samples: Array<Obje
```
```
__
_
#### **`getSleepSamples`**
query for sleep samples.
each sleep sample represents a period of time with a startDate and an endDate.
the sample's value will be either
`INBED`
or
`ASLEEP`
. these values should overlap,
meaning that two samples represent a single nights sleep activity. see
[HealthKit SleepAnalysis] reference documentation
the options object is used to setup a query to retrieve relevant samples.
the options must contain
`startDate`
and may also optionally include
`endDate`
and
`limit`
options
```
javascript
let
options
=
{
startDate
:
(
new
Date
(
2016
,
10
,
1
)).
toISOString
(),
// required
endDate
:
(
new
Date
()).
toISOString
(),
// optional; default now
limit
:
10
,
// optional; default no limit
};
```
the callback function will be called with a
`samples`
array containing objects
with
*value*
,
*startDate*
, and
*endDate*
fields
*example usage*
```
javascript
AppleHealthKit
.
getSleepSamples
(
options
,
(
err
:
Object
,
samples
:
Array
<
Object
>
)
=>
{
if
(
this
.
_handleHealthKitError
(
err
,
'
getSleepSamples
'
)){
return
;
}
// use samples ...
});
```
## Examples
## Examples
...
@@ -892,3 +930,4 @@ AppleHealthKit.getBloodGlucoseSamples(options, (err: Object, samples: Array<Obje
...
@@ -892,3 +930,4 @@ AppleHealthKit.getBloodGlucoseSamples(options, (err: Object, samples: Array<Obje
[
Apple HealthKit
]:
https://developer.apple.com/healthkit/
[
Apple HealthKit
]:
https://developer.apple.com/healthkit/
[
react-native-apple-healthkit
]:
https://www.npmjs.com/package/react-native-apple-healthkit
[
react-native-apple-healthkit
]:
https://www.npmjs.com/package/react-native-apple-healthkit
[
HealthKit SleepAnalysis
]:
https://developer.apple.com/reference/healthkit/hkcategoryvaluesleepanalysis?language=objc
examples/StepsDemo/ios/StepsDemo.xcodeproj/project.pbxproj
View file @
4d738c38
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
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 */
;
};
37837E961DCFE49D000201A0
/* libRCTAppleHealthKit.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
37837E951DCFE493000201A0
/* 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 */
...
@@ -90,6 +91,13 @@
...
@@ -90,6 +91,13 @@
remoteGlobalIDString
=
83CBBA2E1A601D0E00E9B192
;
remoteGlobalIDString
=
83CBBA2E1A601D0E00E9B192
;
remoteInfo
=
React
;
remoteInfo
=
React
;
};
};
37837E941DCFE493000201A0
/* PBXContainerItemProxy */
=
{
isa
=
PBXContainerItemProxy
;
containerPortal
=
37837E901DCFE493000201A0
/* RCTAppleHealthKit.xcodeproj */
;
proxyType
=
2
;
remoteGlobalIDString
=
3774C88D1D2092F20000B3F3
;
remoteInfo
=
RCTAppleHealthKit
;
};
78C398B81ACF4ADC00677621
/* PBXContainerItemProxy */
=
{
78C398B81ACF4ADC00677621
/* PBXContainerItemProxy */
=
{
isa
=
PBXContainerItemProxy
;
isa
=
PBXContainerItemProxy
;
containerPortal
=
78C398B01ACF4ADC00677621
/* RCTLinking.xcodeproj */
;
containerPortal
=
78C398B01ACF4ADC00677621
/* RCTLinking.xcodeproj */
;
...
@@ -126,6 +134,7 @@
...
@@ -126,6 +134,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>"
;
};
37837E901DCFE493000201A0
/* 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>"
;
};
...
@@ -145,6 +154,7 @@
...
@@ -145,6 +154,7 @@
isa
=
PBXFrameworksBuildPhase
;
isa
=
PBXFrameworksBuildPhase
;
buildActionMask
=
2147483647
;
buildActionMask
=
2147483647
;
files
=
(
files
=
(
37837E961DCFE49D000201A0
/* 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 */
,
...
@@ -258,6 +268,14 @@
...
@@ -258,6 +268,14 @@
name
=
Products
;
name
=
Products
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
};
};
37837E911DCFE493000201A0
/* Products */
=
{
isa
=
PBXGroup
;
children
=
(
37837E951DCFE493000201A0
/* libRCTAppleHealthKit.a */
,
);
name
=
Products
;
sourceTree
=
"<group>"
;
};
78C398B11ACF4ADC00677621
/* Products */
=
{
78C398B11ACF4ADC00677621
/* Products */
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
...
@@ -269,6 +287,7 @@
...
@@ -269,6 +287,7 @@
832341AE1AAA6A7D00B99B32
/* Libraries */
=
{
832341AE1AAA6A7D00B99B32
/* Libraries */
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
37837E901DCFE493000201A0
/* RCTAppleHealthKit.xcodeproj */
,
146833FF1AC3E56700842450
/* React.xcodeproj */
,
146833FF1AC3E56700842450
/* React.xcodeproj */
,
00C302A71ABCB8CE00DB3ED1
/* RCTActionSheet.xcodeproj */
,
00C302A71ABCB8CE00DB3ED1
/* RCTActionSheet.xcodeproj */
,
00C302B51ABCB90400DB3ED1
/* RCTGeolocation.xcodeproj */
,
00C302B51ABCB90400DB3ED1
/* RCTGeolocation.xcodeproj */
,
...
@@ -391,6 +410,10 @@
...
@@ -391,6 +410,10 @@
ProductGroup
=
00C302A81ABCB8CE00DB3ED1
/* Products */
;
ProductGroup
=
00C302A81ABCB8CE00DB3ED1
/* Products */
;
ProjectRef
=
00C302A71ABCB8CE00DB3ED1
/* RCTActionSheet.xcodeproj */
;
ProjectRef
=
00C302A71ABCB8CE00DB3ED1
/* RCTActionSheet.xcodeproj */
;
},
},
{
ProductGroup
=
37837E911DCFE493000201A0
/* Products */
;
ProjectRef
=
37837E901DCFE493000201A0
/* RCTAppleHealthKit.xcodeproj */
;
},
{
{
ProductGroup
=
00C302B61ABCB90400DB3ED1
/* Products */
;
ProductGroup
=
00C302B61ABCB90400DB3ED1
/* Products */
;
ProjectRef
=
00C302B51ABCB90400DB3ED1
/* RCTGeolocation.xcodeproj */
;
ProjectRef
=
00C302B51ABCB90400DB3ED1
/* RCTGeolocation.xcodeproj */
;
...
@@ -493,6 +516,13 @@
...
@@ -493,6 +516,13 @@
remoteRef
=
146834031AC3E56700842450
/* PBXContainerItemProxy */
;
remoteRef
=
146834031AC3E56700842450
/* PBXContainerItemProxy */
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
};
37837E951DCFE493000201A0
/* libRCTAppleHealthKit.a */
=
{
isa
=
PBXReferenceProxy
;
fileType
=
archive.ar
;
path
=
libRCTAppleHealthKit.a
;
remoteRef
=
37837E941DCFE493000201A0
/* PBXContainerItemProxy */
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
78C398B91ACF4ADC00677621
/* libRCTLinking.a */
=
{
78C398B91ACF4ADC00677621
/* libRCTLinking.a */
=
{
isa
=
PBXReferenceProxy
;
isa
=
PBXReferenceProxy
;
fileType
=
archive.ar
;
fileType
=
archive.ar
;
...
...
examples/StepsDemo/package.json
View file @
4d738c38
...
@@ -9,7 +9,6 @@
...
@@ -9,7 +9,6 @@
"lodash"
:
"^4.13.1"
,
"lodash"
:
"^4.13.1"
,
"react"
:
"15.1.0"
,
"react"
:
"15.1.0"
,
"react-mixin"
:
"^2.0.2"
,
"react-mixin"
:
"^2.0.2"
,
"react-native"
:
"^0.28.0"
,
"react-native"
:
"^0.28.0"
"react-native-apple-healthkit"
:
"file:///Users/greg/Dev/experimental/RCTAppleHealthKit"
}
}
}
}
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