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
cd372698
Commit
cd372698
authored
Jul 13, 2016
by
Daniele Volpi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added fetchCorrelationSamplesOfType method and blood pressure samples vitals method
parent
7ae8a2d1
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
118 additions
and
3 deletions
+118
-3
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Vitals.h
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Vitals.h
+1
-3
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Vitals.m
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Vitals.m
+56
-0
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
+53
-0
RCTAppleHealthKit/RCTAppleHealthKit+Utils.m
RCTAppleHealthKit/RCTAppleHealthKit+Utils.m
+3
-0
RCTAppleHealthKit/RCTAppleHealthKit.m
RCTAppleHealthKit/RCTAppleHealthKit.m
+4
-0
constants.js
constants.js
+1
-0
No files found.
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Vitals.h
View file @
cd372698
...
@@ -6,9 +6,7 @@
...
@@ -6,9 +6,7 @@
-
(
void
)
vitals_getBodyTemperatureSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
vitals_getBodyTemperatureSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
vitals_getBloodPressureSystolicSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
vitals_getBloodPressureSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
vitals_getBloodPressureDiastolicSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
vitals_getRespiratoryRateSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
vitals_getRespiratoryRateSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
...
...
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Vitals.m
View file @
cd372698
...
@@ -72,4 +72,60 @@
...
@@ -72,4 +72,60 @@
}];
}];
}
}
-
(
void
)
vitals_getBloodPressureSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
{
HKCorrelationType
*
bloodPressureCorrelationType
=
[
HKCorrelationType
correlationTypeForIdentifier
:
HKCorrelationTypeIdentifierBloodPressure
];
HKQuantityType
*
systolicType
=
[
HKQuantityType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierBloodPressureSystolic
];
HKQuantityType
*
diastolicType
=
[
HKQuantityType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierBloodPressureDiastolic
];
HKUnit
*
unit
=
[
RCTAppleHealthKit
hkUnitFromOptions
:
input
key
:
@"unit"
withDefault
:
[
HKUnit
millimeterOfMercuryUnit
]];
NSUInteger
limit
=
[
RCTAppleHealthKit
uintFromOptions
:
input
key
:
@"limit"
withDefault
:
HKObjectQueryNoLimit
];
BOOL
ascending
=
[
RCTAppleHealthKit
boolFromOptions
:
input
key
:
@"ascending"
withDefault
:
false
];
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
];
[
self
fetchCorrelationSamplesOfType
:
bloodPressureCorrelationType
unit:
unit
predicate:
predicate
ascending:
ascending
limit:
limit
completion:
^
(
NSArray
*
results
,
NSError
*
error
)
{
if
(
results
){
NSMutableArray
*
data
=
[
NSMutableArray
arrayWithCapacity
:
1
];
for
(
NSDictionary
*
sample
in
results
)
{
HKCorrelation
*
bloodPressureValues
=
[
sample
valueForKey
:
@"correlation"
];
HKQuantitySample
*
bloodPressureSystolicValue
=
[
bloodPressureValues
objectsForType
:
systolicType
].
anyObject
;
HKQuantitySample
*
bloodPressureDiastolicValue
=
[
bloodPressureValues
objectsForType
:
diastolicType
].
anyObject
;
NSDictionary
*
elem
=
@{
@"bloodPressureSystolicValue"
:
@
([
bloodPressureSystolicValue
.
quantity
doubleValueForUnit
:
unit
]),
@"bloodPressureDiastolicValue"
:
@
([
bloodPressureDiastolicValue
.
quantity
doubleValueForUnit
:
unit
]),
@"startDate"
:
[
sample
valueForKey
:
@"startDate"
],
@"endDate"
:
[
sample
valueForKey
:
@"endDate"
],
};
[
data
addObject
:
elem
];
}
callback
(@[[
NSNull
null
],
data
]);
return
;
}
else
{
NSLog
(
@"error getting blood pressure samples: %@"
,
error
);
callback
(@[
RCTMakeError
(
@"error getting blood pressure samples"
,
nil
,
nil
)]);
return
;
}
}];
}
@end
@end
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
View file @
cd372698
...
@@ -108,7 +108,60 @@
...
@@ -108,7 +108,60 @@
}
}
-
(
void
)
fetchCorrelationSamplesOfType
:(
HKQuantityType
*
)
quantityType
unit
:(
HKUnit
*
)
unit
predicate
:(
NSPredicate
*
)
predicate
ascending
:(
BOOL
)
asc
limit
:(
NSUInteger
)
lim
completion
:(
void
(
^
)(
NSArray
*
,
NSError
*
))
completion
{
NSSortDescriptor
*
timeSortDescriptor
=
[[
NSSortDescriptor
alloc
]
initWithKey
:
HKSampleSortIdentifierEndDate
ascending:
asc
];
// 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
(
HKCorrelation
*
sample
in
results
)
{
NSString
*
startDateString
=
[
RCTAppleHealthKit
buildISO8601StringFromDate
:
sample
.
startDate
];
NSString
*
endDateString
=
[
RCTAppleHealthKit
buildISO8601StringFromDate
:
sample
.
endDate
];
NSDictionary
*
elem
=
@{
@"correlation"
:
sample
,
@"startDate"
:
startDateString
,
@"endDate"
:
endDateString
,
};
[
data
addObject
:
elem
];
}
completion
(
data
,
error
);
});
}
};
HKSampleQuery
*
query
=
[[
HKSampleQuery
alloc
]
initWithSampleType
:
quantityType
predicate:
predicate
limit:
lim
sortDescriptors:
@[
timeSortDescriptor
]
resultsHandler:
handlerBlock
];
[
self
.
healthStore
executeQuery
:
query
];
}
...
...
RCTAppleHealthKit/RCTAppleHealthKit+Utils.m
View file @
cd372698
...
@@ -237,6 +237,9 @@
...
@@ -237,6 +237,9 @@
if
([
unitString
isEqualToString
:
@"celsius"
]){
if
([
unitString
isEqualToString
:
@"celsius"
]){
theUnit
=
[
HKUnit
degreeCelsiusUnit
];
theUnit
=
[
HKUnit
degreeCelsiusUnit
];
}
}
if
([
unitString
isEqualToString
:
@"mmhg"
]){
theUnit
=
[
HKUnit
millimeterOfMercuryUnit
];
}
if
(
theUnit
==
nil
){
if
(
theUnit
==
nil
){
theUnit
=
defaultValue
;
theUnit
=
defaultValue
;
...
...
RCTAppleHealthKit/RCTAppleHealthKit.m
View file @
cd372698
...
@@ -145,6 +145,10 @@ RCT_EXPORT_METHOD(getBodyTemperatureSamples:(NSDictionary *)input callback:(RCTR
...
@@ -145,6 +145,10 @@ RCT_EXPORT_METHOD(getBodyTemperatureSamples:(NSDictionary *)input callback:(RCTR
[
self
vitals_getBodyTemperatureSamples
:
input
callback
:
callback
];
[
self
vitals_getBodyTemperatureSamples
:
input
callback
:
callback
];
}
}
RCT_EXPORT_METHOD
(
getBloodPressureSamples
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
{
[
self
vitals_getBloodPressureSamples
:
input
callback
:
callback
];
}
RCT_EXPORT_METHOD
(
getInfo
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
RCT_EXPORT_METHOD
(
getInfo
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
...
...
constants.js
View file @
cd372698
...
@@ -46,6 +46,7 @@ const UNITS = {
...
@@ -46,6 +46,7 @@ const UNITS = {
bpm
:
'
bpm
'
,
bpm
:
'
bpm
'
,
fahrenheit
:
'
fahrenheit
'
,
fahrenheit
:
'
fahrenheit
'
,
celsius
:
'
celsius
'
,
celsius
:
'
celsius
'
,
mmhg
:
'
mmhg
'
,
};
};
...
...
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