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
dda3ea95
Commit
dda3ea95
authored
Jan 30, 2018
by
EEvgeniiF
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
isTracked step samples
parent
15e89ceb
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
137 additions
and
33 deletions
+137
-33
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.h
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.h
+1
-2
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.m
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.m
+1
-2
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Characteristic.h
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Characteristic.h
+1
-2
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Characteristic.m
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Characteristic.m
+1
-2
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Fitness.h
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Fitness.h
+2
-2
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Fitness.m
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Fitness.m
+50
-2
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.h
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.h
+1
-2
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.m
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.m
+1
-2
RCTAppleHealthKit/RCTAppleHealthKit+Queries.h
RCTAppleHealthKit/RCTAppleHealthKit+Queries.h
+9
-2
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
+59
-3
RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.h
RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.h
+1
-2
RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m
RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m
+1
-2
RCTAppleHealthKit/RCTAppleHealthKit+Utils.h
RCTAppleHealthKit/RCTAppleHealthKit+Utils.h
+1
-2
RCTAppleHealthKit/RCTAppleHealthKit+Utils.m
RCTAppleHealthKit/RCTAppleHealthKit+Utils.m
+1
-2
RCTAppleHealthKit/RCTAppleHealthKit.h
RCTAppleHealthKit/RCTAppleHealthKit.h
+1
-2
RCTAppleHealthKit/RCTAppleHealthKit.m
RCTAppleHealthKit/RCTAppleHealthKit.m
+6
-2
No files found.
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.h
View file @
dda3ea95
...
...
@@ -3,8 +3,7 @@
// RCTAppleHealthKit
//
// Created by Greg Wilson on 2016-06-26.
// This source code is licensed under the MIT-style license found in the
// LICENSE file in the root directory of this source tree.
// Copyright © 2016 Greg Wilson. All rights reserved.
//
#import "RCTAppleHealthKit.h"
...
...
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Body.m
View file @
dda3ea95
...
...
@@ -3,8 +3,7 @@
// RCTAppleHealthKit
//
// Created by Greg Wilson on 2016-06-26.
// This source code is licensed under the MIT-style license found in the
// LICENSE file in the root directory of this source tree.
// Copyright © 2016 Greg Wilson. All rights reserved.
//
#import "RCTAppleHealthKit+Methods_Body.h"
...
...
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Characteristic.h
View file @
dda3ea95
...
...
@@ -3,8 +3,7 @@
// RCTAppleHealthKit
//
// Created by Greg Wilson on 2016-06-29.
// This source code is licensed under the MIT-style license found in the
// LICENSE file in the root directory of this source tree.
// Copyright © 2016 Greg Wilson. All rights reserved.
//
#import "RCTAppleHealthKit.h"
...
...
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Characteristic.m
View file @
dda3ea95
...
...
@@ -3,8 +3,7 @@
// RCTAppleHealthKit
//
// Created by Greg Wilson on 2016-06-29.
// This source code is licensed under the MIT-style license found in the
// LICENSE file in the root directory of this source tree.
// Copyright © 2016 Greg Wilson. All rights reserved.
//
#import "RCTAppleHealthKit+Methods_Characteristic.h"
...
...
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Fitness.h
View file @
dda3ea95
...
...
@@ -3,8 +3,7 @@
// RCTAppleHealthKit
//
// Created by Greg Wilson on 2016-06-26.
// This source code is licensed under the MIT-style license found in the
// LICENSE file in the root directory of this source tree.
// Copyright © 2016 Greg Wilson. All rights reserved.
//
#import "RCTAppleHealthKit.h"
...
...
@@ -12,6 +11,7 @@
@interface
RCTAppleHealthKit
(
Methods_Fitness
)
-
(
void
)
fitness_getStepCountOnDay
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
fitness_getStepCountSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
fitness_getDailyStepSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
fitness_saveSteps
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
-
(
void
)
fitness_initializeStepEventObserver
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
;
...
...
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Fitness.m
View file @
dda3ea95
...
...
@@ -3,8 +3,7 @@
// RCTAppleHealthKit
//
// Created by Greg Wilson on 2016-06-26.
// This source code is licensed under the MIT-style license found in the
// LICENSE file in the root directory of this source tree.
// Copyright © 2016 Greg Wilson. All rights reserved.
//
#import "RCTAppleHealthKit+Methods_Fitness.h"
...
...
@@ -49,6 +48,55 @@
}];
}
-
(
void
)
fitness_getStepCountSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
{
HKUnit
*
unit
=
[
RCTAppleHealthKit
hkUnitFromOptions
:
input
key
:
@"unit"
withDefault
:
[
HKUnit
countUnit
]];
NSUInteger
limit
=
[
RCTAppleHealthKit
uintFromOptions
:
input
key
:
@"limit"
withDefault
:
HKObjectQueryNoLimit
];
BOOL
ascending
=
[
RCTAppleHealthKit
boolFromOptions
:
input
key
:
@"ascending"
withDefault
:
false
];
BOOL
isTracked
=
[
RCTAppleHealthKit
boolFromOptions
:
input
key
:
@"isTracked"
withDefault
:
true
];
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
;
}
NSDateFormatter
*
formatter
=
[[
NSDateFormatter
alloc
]
init
];
[
formatter
setDateFormat
:
@"YYYY-MM-dd-hh-mm-ss"
];
NSLog
(
@"samples interval: %@ %@"
,[
formatter
stringFromDate
:
startDate
],
[
formatter
stringFromDate
:
endDate
]);
// no isTracked
NSArray
*
subPredicates
=
[[
NSArray
alloc
]
init
];
NSMutableArray
*
subPredicatesAux
=
[[
NSMutableArray
alloc
]
init
];
NSPredicate
*
predicateDate
=
[
HKQuery
predicateForSamplesWithStartDate
:
startDate
endDate
:
endDate
options
:
HKQueryOptionStrictStartDate
];
NSPredicate
*
predicateType
=
isTracked
?
[
NSPredicate
predicateWithFormat
:
@"metadata.%K != YES"
,
HKMetadataKeyWasUserEntered
]
:
[
NSPredicate
predicateWithFormat
:
@"metadata.%K == YES"
,
HKMetadataKeyWasUserEntered
];
[
subPredicatesAux
addObject
:
predicateDate
];
[
subPredicatesAux
addObject
:
predicateType
];
subPredicates
=
[
subPredicatesAux
copy
];
NSPredicate
*
predicate
=
[
NSCompoundPredicate
andPredicateWithSubpredicates
:
subPredicates
];
HKQuantityType
*
stepCountType
=
[
HKObjectType
quantityTypeForIdentifier
:
HKQuantityTypeIdentifierStepCount
];
NSString
*
paramName
=
@"isTracked"
;
[
self
fetchQuantitySamplesOfType
:
stepCountType
unit:
unit
predicate:
predicate
ascending:
ascending
limit:
limit
additionalParamName:
paramName
additionalParam:
isTracked
completion:
^
(
NSArray
*
results
,
NSError
*
error
)
{
if
(
results
){
callback
(@[[
NSNull
null
],
results
]);
return
;
}
else
{
NSLog
(
@"error getting active energy burned samples: %@"
,
error
);
callback
(@[
RCTMakeError
(
@"error getting active energy burned samples"
,
nil
,
nil
)]);
return
;
}
}];
}
-
(
void
)
fitness_getDailyStepSamples
:(
NSDictionary
*
)
input
callback
:(
RCTResponseSenderBlock
)
callback
{
...
...
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.h
View file @
dda3ea95
...
...
@@ -3,8 +3,7 @@
// RCTAppleHealthKit
//
// Created by Greg Wilson on 2016-11-06.
// This source code is licensed under the MIT-style license found in the
// LICENSE file in the root directory of this source tree.
// Copyright © 2016 Greg Wilson. All rights reserved.
//
#import "RCTAppleHealthKit.h"
...
...
RCTAppleHealthKit/RCTAppleHealthKit+Methods_Sleep.m
View file @
dda3ea95
...
...
@@ -3,8 +3,7 @@
// RCTAppleHealthKit
//
// Created by Greg Wilson on 2016-11-06.
// This source code is licensed under the MIT-style license found in the
// LICENSE file in the root directory of this source tree.
// Copyright © 2016 Greg Wilson. All rights reserved.
//
...
...
RCTAppleHealthKit/RCTAppleHealthKit+Queries.h
View file @
dda3ea95
...
...
@@ -3,8 +3,7 @@
// RCTAppleHealthKit
//
// Created by Greg Wilson on 2016-06-26.
// This source code is licensed under the MIT-style license found in the
// LICENSE file in the root directory of this source tree.
// Copyright © 2016 Greg Wilson. All rights reserved.
//
#import "RCTAppleHealthKit.h"
...
...
@@ -25,6 +24,14 @@
ascending
:(
BOOL
)
asc
limit
:(
NSUInteger
)
lim
completion
:(
void
(
^
)(
NSArray
*
,
NSError
*
))
completion
;
-
(
void
)
fetchQuantitySamplesOfType
:(
HKQuantityType
*
)
quantityType
unit
:(
HKUnit
*
)
unit
predicate
:(
NSPredicate
*
)
predicate
ascending
:(
BOOL
)
asc
limit
:(
NSUInteger
)
lim
additionalParamName
:(
NSString
*
)
paramName
additionalParam
:(
BOOL
)
param
completion
:(
void
(
^
)(
NSArray
*
,
NSError
*
))
completion
;
-
(
void
)
fetchCorrelationSamplesOfType
:(
HKQuantityType
*
)
quantityType
unit
:(
HKUnit
*
)
unit
predicate
:(
NSPredicate
*
)
predicate
...
...
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
View file @
dda3ea95
...
...
@@ -3,8 +3,7 @@
// RCTAppleHealthKit
//
// Created by Greg Wilson on 2016-06-26.
// This source code is licensed under the MIT-style license found in the
// LICENSE file in the root directory of this source tree.
// Copyright © 2016 Greg Wilson. All rights reserved.
//
#import "RCTAppleHealthKit+Queries.h"
...
...
@@ -106,7 +105,64 @@
[
self
.
healthStore
executeQuery
:
query
];
}
-
(
void
)
fetchQuantitySamplesOfType
:(
HKQuantityType
*
)
quantityType
unit
:(
HKUnit
*
)
unit
predicate
:(
NSPredicate
*
)
predicate
ascending
:(
BOOL
)
asc
limit
:(
NSUInteger
)
lim
additionalParamName
:(
NSString
*
)
paramName
additionalParam
:(
BOOL
)
param
completion
:(
void
(
^
)(
NSArray
*
,
NSError
*
))
completion
{
NSSortDescriptor
*
timeSortDescriptor
=
[[
NSSortDescriptor
alloc
]
initWithKey
:
HKSampleSortIdentifierEndDate
ascending:
asc
];
// declare the block
void
(
^
handlerBlock
)(
HKSampleQuery
*
query
,
NSArray
*
results
,
NSError
*
error
);
// create and assign the block
handlerBlock
=
^
(
HKSampleQuery
*
query
,
NSArray
*
results
,
NSError
*
error
)
{
if
(
!
results
)
{
if
(
completion
)
{
completion
(
nil
,
error
);
}
return
;
}
if
(
completion
)
{
NSMutableArray
*
data
=
[
NSMutableArray
arrayWithCapacity
:
1
];
dispatch_async
(
dispatch_get_main_queue
(),
^
{
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
);
});
}
};
HKSampleQuery
*
query
=
[[
HKSampleQuery
alloc
]
initWithSampleType
:
quantityType
predicate:
predicate
limit:
lim
sortDescriptors:
@[
timeSortDescriptor
]
resultsHandler:
handlerBlock
];
[
self
.
healthStore
executeQuery
:
query
];
}
...
...
RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.h
View file @
dda3ea95
...
...
@@ -3,8 +3,7 @@
// RCTAppleHealthKit
//
// Created by Greg Wilson on 2016-06-26.
// This source code is licensed under the MIT-style license found in the
// LICENSE file in the root directory of this source tree.
// Copyright © 2016 Greg Wilson. All rights reserved.
//
#import "RCTAppleHealthKit.h"
...
...
RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m
View file @
dda3ea95
...
...
@@ -3,8 +3,7 @@
// RCTAppleHealthKit
//
// Created by Greg Wilson on 2016-06-26.
// This source code is licensed under the MIT-style license found in the
// LICENSE file in the root directory of this source tree.
// Copyright © 2016 Greg Wilson. All rights reserved.
//
#import "RCTAppleHealthKit+TypesAndPermissions.h"
...
...
RCTAppleHealthKit/RCTAppleHealthKit+Utils.h
View file @
dda3ea95
...
...
@@ -3,8 +3,7 @@
// RCTAppleHealthKit
//
// Created by Greg Wilson on 2016-06-26.
// This source code is licensed under the MIT-style license found in the
// LICENSE file in the root directory of this source tree.
// Copyright © 2016 Greg Wilson. All rights reserved.
//
#import "RCTAppleHealthKit.h"
...
...
RCTAppleHealthKit/RCTAppleHealthKit+Utils.m
View file @
dda3ea95
...
...
@@ -3,8 +3,7 @@
// RCTAppleHealthKit
//
// Created by Greg Wilson on 2016-06-26.
// This source code is licensed under the MIT-style license found in the
// LICENSE file in the root directory of this source tree.
// Copyright © 2016 Greg Wilson. All rights reserved.
//
#import "RCTAppleHealthKit+Utils.h"
...
...
RCTAppleHealthKit/RCTAppleHealthKit.h
View file @
dda3ea95
...
...
@@ -3,8 +3,7 @@
// RCTAppleHealthKit
//
// Created by Greg Wilson on 2016-06-26.
// This source code is licensed under the MIT-style license found in the
// LICENSE file in the root directory of this source tree.
// Copyright © 2016 Greg Wilson. All rights reserved.
//
#import <Foundation/Foundation.h>
...
...
RCTAppleHealthKit/RCTAppleHealthKit.m
View file @
dda3ea95
...
...
@@ -3,8 +3,7 @@
// RCTAppleHealthKit
//
// Created by Greg Wilson on 2016-06-26.
// This source code is licensed under the MIT-style license found in the
// LICENSE file in the root directory of this source tree.
// Copyright © 2016 Greg Wilson. All rights reserved.
//
#import "RCTAppleHealthKit.h"
...
...
@@ -107,6 +106,11 @@ RCT_EXPORT_METHOD(getStepCount:(NSDictionary *)input callback:(RCTResponseSender
[
self
fitness_getStepCountOnDay
:
input
callback
:
callback
];
}
RCT_EXPORT_METHOD
(
getStepCountSamples
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
{
[
self
fitness_getStepCountSamples
:
input
callback
:
callback
];
}
RCT_EXPORT_METHOD
(
getDailyStepCountSamples
:
(
NSDictionary
*
)
input
callback
:
(
RCTResponseSenderBlock
)
callback
)
{
[
self
fitness_getDailyStepSamples
:
input
callback
:
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