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
909d2e53
Commit
909d2e53
authored
Jul 14, 2016
by
Daniele Volpi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added getBloodGlucoseSamples method and types mmol/L and mg/dL
parent
bcbaf22e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
0 deletions
+46
-0
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Results.m
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Results.m
+32
-0
RCTAppleHealthKit/RCTAppleHealthKit+Utils.m
RCTAppleHealthKit/RCTAppleHealthKit+Utils.m
+6
-0
RCTAppleHealthKit/RCTAppleHealthKit.m
RCTAppleHealthKit/RCTAppleHealthKit.m
+6
-0
constants.js
constants.js
+2
-0
No files found.
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Results.m
View file @
909d2e53
...
@@ -4,7 +4,39 @@
...
@@ -4,7 +4,39 @@
@implementation
RCTAppleHealthKit
(
Methods_Results
)
@implementation
RCTAppleHealthKit
(
Methods_Results
)
-
(
void
)
results_getBloodGlucoseSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
{
HKQuantityType
*
bloodGlucoseType
=
[
HKQuantityType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierBloodGlucose
];
HKUnit
*
mmoLPerL
=
[[
HKUnit
moleUnitWithMetricPrefix
:
HKMetricPrefixMilli
molarMass
:
HKUnitMolarMassBloodGlucose
]
unitDividedByUnit
:
[
HKUnit
literUnit
]]
HKUnit
*
unit
=
[
RCTAppleHealthKit
hkUnitFromOptions
:
input
key
:
@"unit"
withDefault
:
mmoLPerL
];
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
fetchQuantitySamplesOfType
:
bloodGlucoseType
unit:
unit
predicate:
predicate
ascending:
ascending
limit:
limit
completion:
^
(
NSArray
*
results
,
NSError
*
error
)
{
if
(
results
){
callback
(@[[
NSNull
null
],
results
]);
return
;
}
else
{
NSLog
(
@"error getting blood glucose samples: %@"
,
error
);
callback
(@[
RCTMakeError
(
@"error getting blood glucose samples"
,
nil
,
nil
)]);
return
;
}
}];
}
@end
@end
RCTAppleHealthKit/RCTAppleHealthKit+Utils.m
View file @
909d2e53
...
@@ -240,6 +240,12 @@
...
@@ -240,6 +240,12 @@
if
([
unitString
isEqualToString
:
@"mmhg"
]){
if
([
unitString
isEqualToString
:
@"mmhg"
]){
theUnit
=
[
HKUnit
millimeterOfMercuryUnit
];
theUnit
=
[
HKUnit
millimeterOfMercuryUnit
];
}
}
if
([
unitString
isEqualToString
:
@"mmolPerL"
]){
theUnit
=
[[
HKUnit
moleUnitWithMetricPrefix
:
HKMetricPrefixMilli
molarMass
:
HKUnitMolarMassBloodGlucose
]
unitDividedByUnit
:
[
HKUnit
literUnit
]];
}
if
([
unitString
isEqualToString
:
@"mgPerL"
]){
theUnit
=
[
HKUnit
unitFromString
:
@"mg/dL"
];
}
if
(
theUnit
==
nil
){
if
(
theUnit
==
nil
){
theUnit
=
defaultValue
;
theUnit
=
defaultValue
;
...
...
RCTAppleHealthKit/RCTAppleHealthKit.m
View file @
909d2e53
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#import "RCTAppleHealthKit+Methods_Fitness.h"
#import "RCTAppleHealthKit+Methods_Fitness.h"
#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"
@implementation
RCTAppleHealthKit
@implementation
RCTAppleHealthKit
...
@@ -155,6 +156,11 @@ RCT_EXPORT_METHOD(getRespiratoryRateSamples:(NSDictionary *)input callback:(RCTR
...
@@ -155,6 +156,11 @@ RCT_EXPORT_METHOD(getRespiratoryRateSamples:(NSDictionary *)input callback:(RCTR
[
self
vitals_getRespiratoryRateSamples
:
input
callback
:
callback
];
[
self
vitals_getRespiratoryRateSamples
:
input
callback
:
callback
];
}
}
RCT_EXPORT_METHOD
(
getBloodGlucoseSamples
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
{
[
self
results_getBloodGlucoseSamples
:
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 @
909d2e53
...
@@ -47,6 +47,8 @@ const UNITS = {
...
@@ -47,6 +47,8 @@ const UNITS = {
fahrenheit
:
'
fahrenheit
'
,
fahrenheit
:
'
fahrenheit
'
,
celsius
:
'
celsius
'
,
celsius
:
'
celsius
'
,
mmhg
:
'
mmhg
'
,
mmhg
:
'
mmhg
'
,
mmolPerL
:
'
mmolPerL
'
,
mgPerL
:
'
mgPerL
'
,
};
};
...
...
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