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
22894714
Commit
22894714
authored
Feb 04, 2018
by
Evgenii Evstropov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add simple (only to console output) support for Workouts retrieving
parent
fd433d53
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
26 deletions
+53
-26
Constants/Permissions.js
Constants/Permissions.js
+2
-1
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Fitness.h
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Fitness.h
+1
-1
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Fitness.m
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Fitness.m
+6
-3
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
+40
-19
RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m
RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m
+2
-0
RCTAppleHealthKit/RCTAppleHealthKit.m
RCTAppleHealthKit/RCTAppleHealthKit.m
+2
-2
No files found.
Constants/Permissions.js
View file @
22894714
...
@@ -29,5 +29,6 @@ export const Permissions = {
...
@@ -29,5 +29,6 @@ export const Permissions = {
SleepAnalysis
:
"
SleepAnalysis
"
,
SleepAnalysis
:
"
SleepAnalysis
"
,
StepCount
:
"
StepCount
"
,
StepCount
:
"
StepCount
"
,
Steps
:
"
Steps
"
,
Steps
:
"
Steps
"
,
Weight
:
"
Weight
"
Weight
:
"
Weight
"
,
Workout
:
"
Workout
"
}
}
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Fitness.h
View file @
22894714
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
@interface
RCTAppleHealthKit
(
Methods_Fitness
)
@interface
RCTAppleHealthKit
(
Methods_Fitness
)
-
(
void
)
fitness_getStepCountOnDay
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
fitness_getStepCountOnDay
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
fitness_getS
tepCountS
amples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
fitness_getSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
fitness_getDailyStepSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
fitness_getDailyStepSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
fitness_saveSteps
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
fitness_saveSteps
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
fitness_initializeStepEventObserver
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
fitness_initializeStepEventObserver
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
...
...
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Fitness.m
View file @
22894714
...
@@ -48,7 +48,7 @@
...
@@ -48,7 +48,7 @@
}];
}];
}
}
-
(
void
)
fitness_getS
tepCountS
amples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
-
(
void
)
fitness_getSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
{
{
HKUnit
*
unit
=
[
RCTAppleHealthKit
hkUnitFromOptions
:
input
key
:
@"unit"
withDefault
:
[
HKUnit
countUnit
]];
HKUnit
*
unit
=
[
RCTAppleHealthKit
hkUnitFromOptions
:
input
key
:
@"unit"
withDefault
:
[
HKUnit
countUnit
]];
NSUInteger
limit
=
[
RCTAppleHealthKit
uintFromOptions
:
input
key
:
@"limit"
withDefault
:
HKObjectQueryNoLimit
];
NSUInteger
limit
=
[
RCTAppleHealthKit
uintFromOptions
:
input
key
:
@"limit"
withDefault
:
HKObjectQueryNoLimit
];
...
@@ -72,9 +72,10 @@
...
@@ -72,9 +72,10 @@
[
subPredicatesAux
addObject
:
predicateDate
];
[
subPredicatesAux
addObject
:
predicateDate
];
[
subPredicatesAux
addObject
:
predicateType
];
[
subPredicatesAux
addObject
:
predicateType
];
subPredicates
=
[
subPredicatesAux
copy
];
subPredicates
=
[
subPredicatesAux
copy
];
NSPredicate
*
predicate
=
[
NSCompoundPredicate
andPredicateWithSubpredicates
:
subPredicates
];
NSPredicate
*
predicate
=
[
NSCompoundPredicate
andPredicateWithSubpredicates
:[
NSArray
arrayWithObjects
:
predicateType
,
predicateDate
,
nil
]];
HK
Quantity
Type
*
samplesType
=
[
HKObjectType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierStepCount
];
HK
Sample
Type
*
samplesType
=
[
HKObjectType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierStepCount
];
if
([
type
isEqual
:
@"Walking"
])
{
if
([
type
isEqual
:
@"Walking"
])
{
samplesType
=
[
HKObjectType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierStepCount
];
samplesType
=
[
HKObjectType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierStepCount
];
}
else
if
([
type
isEqual
:
@"StairClimbing"
])
{
}
else
if
([
type
isEqual
:
@"StairClimbing"
])
{
...
@@ -85,6 +86,8 @@
...
@@ -85,6 +86,8 @@
}
else
if
([
type
isEqual
:
@"Cycling"
]){
}
else
if
([
type
isEqual
:
@"Cycling"
]){
samplesType
=
[
HKObjectType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierDistanceCycling
];
samplesType
=
[
HKObjectType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierDistanceCycling
];
unit
=
[
HKUnit
mileUnit
];
unit
=
[
HKUnit
mileUnit
];
}
else
if
([
type
isEqual
:
@"Workout"
]){
samplesType
=
[
HKObjectType
workoutType
];
}
}
NSString
*
paramName
=
@"isTracked"
;
NSString
*
paramName
=
@"isTracked"
;
...
...
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
View file @
22894714
...
@@ -105,7 +105,7 @@
...
@@ -105,7 +105,7 @@
[
self
.
healthStore
executeQuery
:
query
];
[
self
.
healthStore
executeQuery
:
query
];
}
}
-
(
void
)
fetchQuantitySamplesOfType
:(
HK
QuantityType
*
)
quantityT
ype
-
(
void
)
fetchQuantitySamplesOfType
:(
HK
SampleType
*
)
t
ype
unit
:(
HKUnit
*
)
unit
unit
:(
HKUnit
*
)
unit
predicate
:(
NSPredicate
*
)
predicate
predicate
:(
NSPredicate
*
)
predicate
ascending
:(
BOOL
)
asc
ascending
:(
BOOL
)
asc
...
@@ -131,22 +131,44 @@
...
@@ -131,22 +131,44 @@
NSMutableArray
*
data
=
[
NSMutableArray
arrayWithCapacity
:
1
];
NSMutableArray
*
data
=
[
NSMutableArray
arrayWithCapacity
:
1
];
dispatch_async
(
dispatch_get_main_queue
(),
^
{
dispatch_async
(
dispatch_get_main_queue
(),
^
{
if
(
type
==
[
HKObjectType
workoutType
])
{
for
(
HKQuantitySample
*
sample
in
results
)
{
for
(
HKWorkout
*
sample
in
results
)
{
HKQuantity
*
quantity
=
sample
.
quantity
;
HKQuantity
*
quantity
=
sample
.
quantity
;
double
value
=
[
quantity
doubleValueForUnit
:
unit
];
double
value
=
[
quantity
doubleValueForUnit
:
unit
];
NSString
*
startDateString
=
[
RCTAppleHealthKit
buildISO8601StringFromDate
:
sample
.
startDate
];
NSString
*
startDateString
=
[
RCTAppleHealthKit
buildISO8601StringFromDate
:
sample
.
startDate
];
NSString
*
endDateString
=
[
RCTAppleHealthKit
buildISO8601StringFromDate
:
sample
.
endDate
];
NSString
*
endDateString
=
[
RCTAppleHealthKit
buildISO8601StringFromDate
:
sample
.
endDate
];
NSDictionary
*
elem
=
@{
NSDictionary
*
elem
=
@{
@"value"
:
@
(
value
),
@"value"
:
@
(
value
),
@"startDate"
:
startDateString
,
@"startDate"
:
startDateString
,
@"endDate"
:
endDateString
,
@"endDate"
:
endDateString
,
paramName
:
@
(
param
),
paramName
:
@
(
param
),
};
};
[
data
addObject
:
elem
];
[
data
addObject
:
elem
];
NSLog
(
@"%lu"
,
(
unsigned
long
)[
sample
workoutActivityType
]);
NSLog
(
@"energy burned %f"
,
[[
sample
totalEnergyBurned
]
doubleValueForUnit
:[
HKUnit
kilocalorieUnit
]]);
NSLog
(
@"total distance %f"
,
[[
sample
totalDistance
]
doubleValueForUnit
:[
HKUnit
mileUnit
]]);
}
}
else
{
for
(
HKQuantitySample
*
sample
in
results
)
{
HKQuantity
*
quantity
=
sample
.
quantity
;
double
value
=
[
quantity
doubleValueForUnit
:
unit
];
NSString
*
startDateString
=
[
RCTAppleHealthKit
buildISO8601StringFromDate
:
sample
.
startDate
];
NSString
*
endDateString
=
[
RCTAppleHealthKit
buildISO8601StringFromDate
:
sample
.
endDate
];
NSDictionary
*
elem
=
@{
@"value"
:
@
(
value
),
@"startDate"
:
startDateString
,
@"endDate"
:
endDateString
,
paramName
:
@
(
param
),
};
[
data
addObject
:
elem
];
}
}
}
completion
(
data
,
error
);
completion
(
data
,
error
);
...
@@ -154,7 +176,7 @@
...
@@ -154,7 +176,7 @@
}
}
};
};
HKSampleQuery
*
query
=
[[
HKSampleQuery
alloc
]
initWithSampleType
:
quantityT
ype
HKSampleQuery
*
query
=
[[
HKSampleQuery
alloc
]
initWithSampleType
:
t
ype
predicate:
predicate
predicate:
predicate
limit:
lim
limit:
lim
sortDescriptors:
@[
timeSortDescriptor
]
sortDescriptors:
@[
timeSortDescriptor
]
...
@@ -168,7 +190,6 @@
...
@@ -168,7 +190,6 @@
-
(
void
)
fetchSleepCategorySamplesForPredicate
:(
NSPredicate
*
)
predicate
-
(
void
)
fetchSleepCategorySamplesForPredicate
:(
NSPredicate
*
)
predicate
limit
:(
NSUInteger
)
lim
limit
:(
NSUInteger
)
lim
completion
:(
void
(
^
)(
NSArray
*
,
NSError
*
))
completion
{
completion
:(
void
(
^
)(
NSArray
*
,
NSError
*
))
completion
{
...
...
RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m
View file @
22894714
...
@@ -49,6 +49,8 @@
...
@@ -49,6 +49,8 @@
@"SleepAnalysis"
:
[
HKObjectType
categoryTypeForIdentifier
:
HKCategoryTypeIdentifierSleepAnalysis
],
@"SleepAnalysis"
:
[
HKObjectType
categoryTypeForIdentifier
:
HKCategoryTypeIdentifierSleepAnalysis
],
// Mindfulness
// Mindfulness
@"MindfulSession"
:
[
HKObjectType
categoryTypeForIdentifier
:
HKCategoryTypeIdentifierMindfulSession
],
@"MindfulSession"
:
[
HKObjectType
categoryTypeForIdentifier
:
HKCategoryTypeIdentifierMindfulSession
],
//workouts
@"Workout"
:
[
HKObjectType
workoutType
],
};
};
return
readPerms
;
return
readPerms
;
}
}
...
...
RCTAppleHealthKit/RCTAppleHealthKit.m
View file @
22894714
...
@@ -106,9 +106,9 @@ RCT_EXPORT_METHOD(getStepCount:(NSDictionary *)input callback:(RCTResponseSender
...
@@ -106,9 +106,9 @@ RCT_EXPORT_METHOD(getStepCount:(NSDictionary *)input callback:(RCTResponseSender
[
self
fitness_getStepCountOnDay
:
input
callback
:
callback
];
[
self
fitness_getStepCountOnDay
:
input
callback
:
callback
];
}
}
RCT_EXPORT_METHOD
(
getS
tepCountS
amples
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
RCT_EXPORT_METHOD
(
getSamples
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
{
{
[
self
fitness_getS
tepCountS
amples
:
input
callback
:
callback
];
[
self
fitness_getSamples
:
input
callback
:
callback
];
}
}
RCT_EXPORT_METHOD
(
getDailyStepCountSamples
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
RCT_EXPORT_METHOD
(
getDailyStepCountSamples
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
...
...
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