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
c2f221a5
Commit
c2f221a5
authored
Apr 17, 2019
by
Andrew Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add getLeanBodyMassSamples and getBodyFatPercentageSamples
parent
aca094bf
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
0 deletions
+79
-0
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.h
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.h
+2
-0
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.m
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.m
+66
-0
RCTAppleHealthKit/RCTAppleHealthKit.m
RCTAppleHealthKit/RCTAppleHealthKit.m
+10
-0
README.md
README.md
+1
-0
No files found.
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.h
View file @
c2f221a5
...
@@ -23,9 +23,11 @@
...
@@ -23,9 +23,11 @@
-
(
void
)
body_saveHeight
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_saveHeight
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_getLatestBodyFatPercentage
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_getLatestBodyFatPercentage
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_getBodyFatPercentageSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_saveBodyFatPercentage
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_saveBodyFatPercentage
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_getLatestLeanBodyMass
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_getLatestLeanBodyMass
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_getLeanBodyMassSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_saveLeanBodyMass
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
body_saveLeanBodyMass
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
@end
@end
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.m
View file @
c2f221a5
...
@@ -257,6 +257,39 @@
...
@@ -257,6 +257,39 @@
}
}
-
(
void
)
body_getBodyFatPercentageSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
{
HKQuantityType
*
bodyFatPercentType
=
[
HKQuantityType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierBodyFatPercentage
];
HKUnit
*
unit
=
[
HKUnit
percentUnit
];
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
:
bodyFatPercentType
unit:
unit
predicate:
predicate
ascending:
ascending
limit:
limit
completion:
^
(
NSArray
*
results
,
NSError
*
error
)
{
if
(
results
){
callback
(@[[
NSNull
null
],
results
]);
return
;
}
else
{
NSLog
(
@"error getting body fat percentage samples: %@"
,
error
);
callback
(@[
RCTMakeError
(
@"error getting body fat percentage samples"
,
nil
,
nil
)]);
return
;
}
}];
}
-
(
void
)
body_saveBodyFatPercentage
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
-
(
void
)
body_saveBodyFatPercentage
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
{
{
double
percentage
=
[
RCTAppleHealthKit
doubleValueFromOptions
:
input
];
double
percentage
=
[
RCTAppleHealthKit
doubleValueFromOptions
:
input
];
...
@@ -307,6 +340,39 @@
...
@@ -307,6 +340,39 @@
}
}
-
(
void
)
body_getLeanBodyMassSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
{
HKQuantityType
*
leanBodyMassType
=
[
HKQuantityType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierLeanBodyMass
];
HKUnit
*
unit
=
[
RCTAppleHealthKit
hkUnitFromOptions
:
input
key
:
@"unit"
withDefault
:
[
HKUnit
poundUnit
]];
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
:
leanBodyMassType
unit:
unit
predicate:
predicate
ascending:
ascending
limit:
limit
completion:
^
(
NSArray
*
results
,
NSError
*
error
)
{
if
(
results
){
callback
(@[[
NSNull
null
],
results
]);
return
;
}
else
{
NSLog
(
@"error getting lean body mass samples: %@"
,
error
);
callback
(@[
RCTMakeError
(
@"error getting lean body mass samples"
,
nil
,
nil
)]);
return
;
}
}];
}
-
(
void
)
body_saveLeanBodyMass
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
-
(
void
)
body_saveLeanBodyMass
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
{
{
double
mass
=
[
RCTAppleHealthKit
doubleValueFromOptions
:
input
];
double
mass
=
[
RCTAppleHealthKit
doubleValueFromOptions
:
input
];
...
...
RCTAppleHealthKit/RCTAppleHealthKit.m
View file @
c2f221a5
...
@@ -99,6 +99,11 @@ RCT_EXPORT_METHOD(getLatestBodyFatPercentage:(NSDictionary *)input callback:(RCT
...
@@ -99,6 +99,11 @@ RCT_EXPORT_METHOD(getLatestBodyFatPercentage:(NSDictionary *)input callback:(RCT
[
self
body_getLatestBodyFatPercentage
:
input
callback
:
callback
];
[
self
body_getLatestBodyFatPercentage
:
input
callback
:
callback
];
}
}
RCT_EXPORT_METHOD
(
getBodyFatPercentageSamples
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
{
[
self
body_getBodyFatPercentageSamples
:
input
callback
:
callback
];
}
RCT_EXPORT_METHOD
(
saveBodyFatPercentage
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
RCT_EXPORT_METHOD
(
saveBodyFatPercentage
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
{
{
[
self
body_saveBodyFatPercentage
:
input
callback
:
callback
];
[
self
body_saveBodyFatPercentage
:
input
callback
:
callback
];
...
@@ -109,6 +114,11 @@ RCT_EXPORT_METHOD(getLatestLeanBodyMass:(NSDictionary *)input callback:(RCTRespo
...
@@ -109,6 +114,11 @@ RCT_EXPORT_METHOD(getLatestLeanBodyMass:(NSDictionary *)input callback:(RCTRespo
[
self
body_getLatestLeanBodyMass
:
input
callback
:
callback
];
[
self
body_getLatestLeanBodyMass
:
input
callback
:
callback
];
}
}
RCT_EXPORT_METHOD
(
getLeanBodyMassSamples
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
{
[
self
body_getLeanBodyMassSamples
:
input
callback
:
callback
];
}
RCT_EXPORT_METHOD
(
saveLeanBodyMass
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
RCT_EXPORT_METHOD
(
saveLeanBodyMass
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
{
{
[
self
body_saveLeanBodyMass
:
input
callback
:
callback
];
[
self
body_saveLeanBodyMass
:
input
callback
:
callback
];
...
...
README.md
View file @
c2f221a5
...
@@ -143,6 +143,7 @@ AppleHealthKit.initHealthKit(options: Object, (err: string, results: Object) =>
...
@@ -143,6 +143,7 @@ AppleHealthKit.initHealthKit(options: Object, (err: string, results: Object) =>
*
[
saveWeight
](
/docs/saveWeight(
)
.md)
*
[
saveWeight
](
/docs/saveWeight(
)
.md)
*
[
saveSteps
](
/docs/saveSteps(
)
.md)
*
[
saveSteps
](
/docs/saveSteps(
)
.md)
*
[
saveBodyFatPercentage
](
/docs/saveBodyFatPercentage(
)
.md)
*
[
saveBodyFatPercentage
](
/docs/saveBodyFatPercentage(
)
.md)
*
[
saveLeanBodyMass
](
/docs/saveLeanBodyMass(
)
.md)
*
[
References
](
#references
)
*
[
References
](
#references
)
## Supported Apple Permissions
## Supported Apple Permissions
...
...
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