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
e3725593
Commit
e3725593
authored
May 18, 2018
by
Evgenii Evstropov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix background workouts observer
parent
2178a8ed
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
15 deletions
+13
-15
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
+12
-15
RCTAppleHealthKit/RCTAppleHealthKit.m
RCTAppleHealthKit/RCTAppleHealthKit.m
+1
-0
No files found.
RCTAppleHealthKit/RCTAppleHealthKit+Queries.m
View file @
e3725593
...
@@ -208,23 +208,20 @@
...
@@ -208,23 +208,20 @@
-
(
void
)
setObserverForType
:(
HKSampleType
*
)
type
-
(
void
)
setObserverForType
:(
HKSampleType
*
)
type
unit
:(
HKUnit
*
)
unit
{
unit
:(
HKUnit
*
)
unit
{
NSLog
(
@"set observer"
);
HKObserverQuery
*
query
=
[[
HKObserverQuery
alloc
]
initWithSampleType
:
type
predicate
:
nil
updateHandler
:^
(
HKObserverQuery
*
query
,
HKObserverQueryCompletionHandler
completionHandler
,
NSError
*
_Nullable
error
){
HKObserverQuery
*
query
=
[[
HKObserverQuery
alloc
]
initWithSampleType
:
type
predicate
:
nil
updateHandler
:^
(
HKObserverQuery
*
query
,
HKObserverQueryCompletionHandler
completionHandler
,
NSError
*
_Nullable
error
){
UIApplication
*
app
=
[
UIApplication
sharedApplication
];
if
(
error
)
{
NSLog
(
@"observer fired"
);
NSLog
(
@"*** An error occured while setting up the stepCount observer. %@ ***"
,
error
.
localizedDescription
);
[
self
.
bridge
.
eventDispatcher
sendAppEventWithName
:
@"observer"
body
:
@""
];
return
;
completionHandler
();
}
// self.isSync = true;
[
self
.
bridge
.
eventDispatcher
sendAppEventWithName
:
@"observer"
body
:
@""
];
// __block UIBackgroundTaskIdentifier backgroundTaskIdentifier = [app beginBackgroundTaskWithExpirationHandler:^{
//
// Theoretically, HealthKit expect that copletionHandler would be called at the end of query process,
// NSLog(@"observer fired from bg");
// but it's unclear how to do in in event paradigm
// [self.bridge.eventDispatcher sendAppEventWithName:@"observer"
// body:@""];
// dispatch_time_t delay = dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC * 5);
//
// dispatch_after(delay, dispatch_get_main_queue(), ^(void){
// [app endBackgroundTask:backgroundTaskIdentifier];
// completionHandler();
// completionHandler();
// self.isSync = false;
// });
// }];
}];
}];
[
self
.
healthStore
executeQuery
:
query
];
[
self
.
healthStore
executeQuery
:
query
];
...
...
RCTAppleHealthKit/RCTAppleHealthKit.m
View file @
e3725593
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#import <React/RCTEventDispatcher.h>
#import <React/RCTEventDispatcher.h>
@implementation
RCTAppleHealthKit
@implementation
RCTAppleHealthKit
@synthesize
bridge
=
_bridge
;
@synthesize
bridge
=
_bridge
;
RCT_EXPORT_MODULE
();
RCT_EXPORT_MODULE
();
...
...
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