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
aca094bf
Commit
aca094bf
authored
Apr 14, 2019
by
Andrew Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add saveLeanBodyMass
parent
08ea5bef
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
1 deletion
+45
-1
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.h
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.h
+1
-0
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.m
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.m
+21
-1
RCTAppleHealthKit/RCTAppleHealthKit.m
RCTAppleHealthKit/RCTAppleHealthKit.m
+5
-0
docs/saveLeanBodyMass().md
docs/saveLeanBodyMass().md
+18
-0
No files found.
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.h
View file @
aca094bf
...
@@ -26,5 +26,6 @@
...
@@ -26,5 +26,6 @@
-
(
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_saveLeanBodyMass
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
@end
@end
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.m
View file @
aca094bf
...
@@ -259,7 +259,6 @@
...
@@ -259,7 +259,6 @@
-
(
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
];
NSDate
*
sampleDate
=
[
RCTAppleHealthKit
dateFromOptionsDefaultNow
:
input
];
NSDate
*
sampleDate
=
[
RCTAppleHealthKit
dateFromOptionsDefaultNow
:
input
];
HKUnit
*
unit
=
[
HKUnit
percentUnit
];
HKUnit
*
unit
=
[
HKUnit
percentUnit
];
...
@@ -307,4 +306,25 @@
...
@@ -307,4 +306,25 @@
}];
}];
}
}
-
(
void
)
body_saveLeanBodyMass
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
{
double
mass
=
[
RCTAppleHealthKit
doubleValueFromOptions
:
input
];
NSDate
*
sampleDate
=
[
RCTAppleHealthKit
dateFromOptions
:
input
key
:
@"startDate"
withDefault
:
[
NSDate
date
]];
HKUnit
*
unit
=
[
RCTAppleHealthKit
hkUnitFromOptions
:
input
key
:
@"unit"
withDefault
:
[
HKUnit
poundUnit
]];
HKQuantity
*
massQuantity
=
[
HKQuantity
quantityWithUnit
:
unit
doubleValue
:
mass
];
HKQuantityType
*
massType
=
[
HKQuantityType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierLeanBodyMass
];
HKQuantitySample
*
massSample
=
[
HKQuantitySample
quantitySampleWithType
:
massType
quantity
:
massQuantity
startDate
:
sampleDate
endDate
:
sampleDate
];
[
self
.
healthStore
saveObject
:
massSample
withCompletion
:
^
(
BOOL
success
,
NSError
*
error
)
{
if
(
!
success
)
{
NSLog
(
@"error saving lean body mass sample: %@"
,
error
);
callback
(@[
RCTMakeError
(
@"error saving lean body mass sample"
,
error
,
nil
)]);
return
;
}
callback
(@[[
NSNull
null
],
@
(
mass
)]);
}];
}
@end
@end
RCTAppleHealthKit/RCTAppleHealthKit.m
View file @
aca094bf
...
@@ -109,6 +109,11 @@ RCT_EXPORT_METHOD(getLatestLeanBodyMass:(NSDictionary *)input callback:(RCTRespo
...
@@ -109,6 +109,11 @@ RCT_EXPORT_METHOD(getLatestLeanBodyMass:(NSDictionary *)input callback:(RCTRespo
[
self
body_getLatestLeanBodyMass
:
input
callback
:
callback
];
[
self
body_getLatestLeanBodyMass
:
input
callback
:
callback
];
}
}
RCT_EXPORT_METHOD
(
saveLeanBodyMass
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
{
[
self
body_saveLeanBodyMass
:
input
callback
:
callback
];
}
RCT_EXPORT_METHOD
(
getStepCount
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
RCT_EXPORT_METHOD
(
getStepCount
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
{
{
[
self
fitness_getStepCountOnDay
:
input
callback
:
callback
];
[
self
fitness_getStepCountOnDay
:
input
callback
:
callback
];
...
...
docs/saveLeanBodyMass().md
0 → 100644
View file @
aca094bf
save a numeric lean body mass value to Healthkit
`saveLeanBodyMass`
accepts an options object containing a numeric weight value:
```
javascript
let
options
=
{
value
:
155.6
// lbs
}
```
```
javascript
AppleHealthKit
.
saveLeanBodyMass
(
options
:
Object
,
(
err
:
Object
,
results
:
Object
)
=>
{
if
(
err
)
{
console
.
log
(
"
error saving lean body mass to Healthkit:
"
,
err
);
return
;
}
// Done
});
```
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