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
a79fc010
Commit
a79fc010
authored
Apr 25, 2019
by
Furyou81
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
67679c39
8c189e9c
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
102 additions
and
37 deletions
+102
-37
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.m
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.m
+4
-15
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
+2
-1
README.md
README.md
+28
-20
docs/getSamples().md
docs/getSamples().md
+52
-0
docs/setObserver().md
docs/setObserver().md
+15
-0
package.json
package.json
+1
-1
No files found.
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.m
View file @
a79fc010
...
...
@@ -18,10 +18,7 @@
{
HKQuantityType
*
weightType
=
[
HKQuantityType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierBodyMass
];
HKUnit
*
unit
=
[
RCTAppleHealthKit
hkUnitFromOptions
:
input
key
:
@"unit"
withDefault
:
[
HKUnit
gramUnitWithMetricPrefix
:
HKMetricPrefixKilo
]];
if
(
unit
==
nil
){
unit
=
[
HKUnit
gramUnit
];
}
HKUnit
*
unit
=
[
RCTAppleHealthKit
hkUnitFromOptions
:
input
key
:
@"unit"
withDefault
:
[
HKUnit
poundUnit
]];
[
self
fetchMostRecentQuantitySampleOfType
:
weightType
predicate:
nil
...
...
@@ -151,11 +148,7 @@
-
(
void
)
body_getLatestHeight
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
{
HKQuantityType
*
heightType
=
[
HKQuantityType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierHeight
];
HKUnit
*
unit
=
[
RCTAppleHealthKit
hkUnitFromOptions
:
input
key
:
@"unit"
withDefault
:
[
HKUnit
meterUnitWithMetricPrefix
:
HKMetricPrefixCenti
]];;
if
(
unit
==
nil
){
unit
=
[
HKUnit
meterUnit
];
}
HKUnit
*
unit
=
[
RCTAppleHealthKit
hkUnitFromOptions
:
input
key
:
@"unit"
withDefault
:
[
HKUnit
inchUnit
]];;
[
self
fetchMostRecentQuantitySampleOfType
:
heightType
predicate:
nil
...
...
@@ -217,11 +210,7 @@
{
double
height
=
[
RCTAppleHealthKit
doubleValueFromOptions
:
input
];
NSDate
*
sampleDate
=
[
RCTAppleHealthKit
dateFromOptionsDefaultNow
:
input
];
HKUnit
*
heightUnit
=
[
RCTAppleHealthKit
hkUnitFromOptions
:
input
key
:
@"unit"
withDefault
:
[
HKUnit
inchUnit
]];;
if
(
heightUnit
==
nil
){
heightUnit
=
[
HKUnit
inchUnit
];
}
HKUnit
*
heightUnit
=
[
RCTAppleHealthKit
hkUnitFromOptions
:
input
key
:
@"unit"
withDefault
:
[
HKUnit
inchUnit
]];
HKQuantity
*
heightQuantity
=
[
HKQuantity
quantityWithUnit
:
heightUnit
doubleValue
:
height
];
HKQuantityType
*
heightType
=
[
HKQuantityType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierHeight
];
...
...
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
View file @
a79fc010
...
...
@@ -156,7 +156,8 @@
}
NSDictionary
*
elem
=
@{
@"activityName"
:
[
NSNumber
numberWithInt
:[
sample
workoutActivityType
]],
@"activityId"
:
[
NSNumber
numberWithInt
:[
sample
workoutActivityType
]],
@"activityName"
:
type
,
@"calories"
:
@
(
energy
),
@"tracked"
:
@
(
isTracked
),
@"sourceName"
:
[[[
sample
sourceRevision
]
source
]
name
],
...
...
README.md
View file @
a79fc010
...
...
@@ -77,6 +77,12 @@ AppleHealthKit.initHealthKit(options: Object, (err: string, results: Object) =>
```
## Changelog
0.
6.5v
-
Enable fetching basal energy
[
#23
](
https://github.com/terrillo/rn-apple-healthkit/pull/23
)
-
remove checkPermission functions in order to use from PR
[
#69
](
https://github.com/terrillo/rn-apple-healthkit/pull/69
)
-
Added correct link to permissions.
[
#73
](
https://github.com/terrillo/rn-apple-healthkit/pull/73
)
-
Add unified way to get workouts + convert Activity Types to name + isTracked flag
[
#25
](
https://github.com/terrillo/rn-apple-healthkit/pull/25
)
0.
6.4v
-
Basal energy (
[
#23
](
https://github.com/terrillo/rn-apple-healthkit/pull/23
)
)
-
Fixed issues with saving weight in the past
...
...
@@ -95,44 +101,46 @@ AppleHealthKit.initHealthKit(options: Object, (err: string, results: Object) =>
## Wiki
*
[
Installation
](
/docs/Install
)
*
[
Documentation
](
#documentation
)
*
[
Permissions
](
#permissions
)
*
[
Permissions
](
#
supported-apple-
permissions
)
*
[
Units
](
#units
)
*
Base Methods
*
[
isAvailable
](
/docs/isAvailable(
)
.md)
*
[
initHealthKit
](
/docs/initHealthKit(
)
.md)
*
Realtime Methods
*
[
initStepCountObserver
](
/docs/initStepCountObserver(
)
.md)
*
[
setObserver
](
/docs/setObserver(
)
.md)
*
Read Methods
*
[
getActiveEnergyBurned
](
/docs/getActiveEnergyBurned(
)
.md)
*
[
getBasalEnergyBurned
](
/docs/getBasalEnergyBurned(
)
.md)
*
[
getBiologicalSex
](
/docs/getBiologicalSex(
)
.md)
*
[
getBloodGlucoseSamples
](
/docs/get
bloodglucoses
amples(
)
.md)
*
[
getBloodPressureSamples
](
/docs/get
bloodpressures
amples(
)
.md)
*
[
getBodyTemperatureSamples
](
/docs/get
bodytemperatures
amples(
)
.md)
*
[
getDailyDistanceCyclingSamples
](
)
*
[
getBloodGlucoseSamples
](
/docs/get
BloodglucoseS
amples(
)
.md)
*
[
getBloodPressureSamples
](
/docs/get
BloodPressureS
amples(
)
.md)
*
[
getBodyTemperatureSamples
](
/docs/get
BodyTemperatureS
amples(
)
.md)
*
[
getDailyDistanceCyclingSamples
](
/docs/getDailyDistanceCyclingSamples(
)
.md
)
*
[
getDailyDistanceWalkingRunningSamples
](
/docs/getDailyDistanceWalkingRunningSamples(
)
.md)
*
[
getDailyFlightsClimbedSamples
](
/docs/getDailyFlightsClimbedSamples(
)
.md)
*
[
getDailyStepCountSamples
](
/docs/getDailyStepCountSamples(
)
.md)
*
[
getDateOfBirth
](
/docs/getDateOfBirth(
)
.md)
*
[
getDistanceCycling
](
/docs/get
distancec
ycling(
)
.md)
*
[
getDistanceCycling
](
/docs/get
DistanceC
ycling(
)
.md)
*
[
getDistanceWalkingRunning
](
/docs/getDistanceWalkingRunning(
)
.md)
*
[
getFlightsClimbed
](
/docs/get
flightsc
limbed(
)
.md)
*
[
getHeartRateSamples
](
/docs/get
heartrates
amples(
)
.md)
*
[
getHeightSamples
](
/docs/get
heights
amples(
)
.md)
*
[
getLatestBmi
](
/docs/get
latestb
mi(
)
.md)
*
[
getLatestBodyFatPercentage
](
/docs/get
latestbodyfatp
ercentage(
)
.md)
*
[
getLatestHeight
](
/docs/get
latesth
eight(
)
.md)
*
[
getLatestLeanBodyMass
](
/docs/get
latestleanbodym
ass(
)
.md)
*
[
getLatestWeight
](
/docs/get
latestw
eight(
)
.md)
*
[
getRespiratoryRateSamples
](
/docs/get
respiratoryrates
amples(
)
.md)
*
[
getSleepSamples
](
/docs/get
sleeps
amples(
)
.md)
*
[
getFlightsClimbed
](
/docs/get
FlightsC
limbed(
)
.md)
*
[
getHeartRateSamples
](
/docs/get
HeartRateS
amples(
)
.md)
*
[
getHeightSamples
](
/docs/get
HeightS
amples(
)
.md)
*
[
getLatestBmi
](
/docs/get
LatestB
mi(
)
.md)
*
[
getLatestBodyFatPercentage
](
/docs/get
LatestBodyFatP
ercentage(
)
.md)
*
[
getLatestHeight
](
/docs/get
LatestH
eight(
)
.md)
*
[
getLatestLeanBodyMass
](
/docs/get
LatestLeanBodyM
ass(
)
.md)
*
[
getLatestWeight
](
/docs/get
LatestW
eight(
)
.md)
*
[
getRespiratoryRateSamples
](
/docs/get
RespiratoryRateS
amples(
)
.md)
*
[
getSleepSamples
](
/docs/get
SleepS
amples(
)
.md)
*
[
getStepCount
](
/docs/getStepCount(
)
.md)
*
[
getWeightSamples
](
/docs/getweightsamples(
)
.md)
*
[
getWeightSamples
](
/docs/getWeightSamples(
)
.md)
*
[
getSamples
](
docs/getSamples(
)
.md)
*
Write Methods
*
[
saveBmi
](
/docs/save
b
mi(
)
.md)
*
[
saveHeight
](
/docs/save
h
eight(
)
.md)
*
[
saveBmi
](
/docs/save
B
mi(
)
.md)
*
[
saveHeight
](
/docs/save
H
eight(
)
.md)
*
[
saveMindfulSession
](
/docs/saveMindfulSession(
)
.md)
*
[
saveWeight
](
/docs/save
w
eight(
)
.md)
*
[
saveWeight
](
/docs/save
W
eight(
)
.md)
*
[
saveSteps
](
/docs/saveSteps(
)
.md)
*
[
References
](
#references
)
...
...
docs/getSamples().md
0 → 100644
View file @
a79fc010
Query to get all activities of given type with extended information about it.
```
javascript 1.7
let options = {
startDate: (new Date(2016,4,27)).toISOString(),
endDate: (new Date()).toISOString(),
type: 'Walking', // one of: ['Walking', 'StairClimbing', 'Running', 'Cycling', 'Workout']
};
```
The callback function will be called with a
`samples`
array containing objects with
*value*
,
*startDate*
, and
*endDate*
fields
```
javascript 1.7
AppleHealthKit.getSamples(options, (err: Object, results: Array<Object>) => {
if (err) {
return;
}
console.log(results)
});
```
Resulting object has different fields for different types.
In case of workout:
```
{
activityId: Number, // [NSNumber numberWithInt:[sample workoutActivityType]]
activityName: Number, // [RCTAppleHealthKit stringForHKWorkoutActivityType:[sample workoutActivityType]]
calories: Number, // [[sample totalEnergyBurned] doubleValueForUnit:[HKUnit kilocalorieUnit]]
tracked: Boolean, // [[sample metadata][HKMetadataKeyWasUserEntered] intValue] !== 1
sourceName: String, // [[[sample sourceRevision] source] name]
sourceId: String, // [[[sample sourceRevision] source] bundleIdentifier]
device: String, // [[sample sourceRevision] productType] or 'iPhone'
distance: Number, // [[sample totalDistance] doubleValueForUnit:[HKUnit mileUnit]]
start: String, // [RCTAppleHealthKit buildISO8601StringFromDate:sample.startDate];
end: String, // [RCTAppleHealthKit buildISO8601StringFromDate:sample.endDate];
}
```
for other types:
```
{
tracked: Boolean, // [[sample metadata][HKMetadataKeyWasUserEntered] intValue] !== 1
sourceName: String, // [[[sample sourceRevision] source] name]
sourceId: String, // [[[sample sourceRevision] source] bundleIdentifier]
device: String, // [[sample sourceRevision] productType] or 'iPhone'
start: String, // [RCTAppleHealthKit buildISO8601StringFromDate:sample.startDate];
end: String, // [RCTAppleHealthKit buildISO8601StringFromDate:sample.endDate];
//based on required type, one of the following will be present.
distance: Number, // [[sample totalDistance] doubleValueForUnit:[HKUnit mileUnit]]
calories: Number, // [[sample totalEnergyBurned] doubleValueForUnit:[HKUnit kilocalorieUnit]]
}
```
docs/setObserver().md
0 → 100644
View file @
a79fc010
Will listen for any updates in a given type data in healthKit and call app.
type - one of the
`['Walking', 'StairClimbing', 'Running', 'Cycling', 'Workout']`
```
javascript 1.8
import { NativeAppEventEmitter } from 'react-native';
//...//
AppleHealthKit.setObserver({ type: 'Walking' });
NativeAppEventEmitter.addListener(
'observer',
callback
);
```
So, callback would be call when new data of given type appears. When it happens, in order to get new info
need to call getSamples() function with proper arguments.
package.json
View file @
a79fc010
{
"name"
:
"rn-apple-healthkit"
,
"version"
:
"0.6.
4
"
,
"version"
:
"0.6.
5
"
,
"description"
:
"A React Native package for interacting with Apple HealthKit"
,
"main"
:
"index.js"
,
"repository"
:
{
...
...
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