[Timer] React Events not fired if the device is locked and screen turned off.
See original GitHub issueIf you have a delegate method that is fired every X seconds in the background when the device is locked. The delegate method is fired but the event is not. The following code
This log message Is triggered when the device is locked and screen is inactive.
NSLog(@"userUUID found %@", userUUID);
This event is triggered if the device is locked but the screen needs to be active.
[self.bridge.eventDispatcher sendDeviceEventWithName:@"nearByUserFound" body:@{@"userUUID":userUUID}];
//
// ProximityManager.m
// Proximity
//
// Created by Adam Bulmer on 07/05/2015.
// Copyright (c) 2015 Adam Bulmer All rights reserved.
//
#import <Foundation/Foundation.h>
#import "ProximityManager.h"
@implementation ProximityManager
@synthesize bridge = _bridge;
// MARK: React Native Bridge
RCT_EXPORT_MODULE()
RCT_EXPORT_METHOD(startAdvertising:(NSString *)appUUID
userUUID:(NSString*)userUUID) {
self.proximity = [[Proximity alloc] initWithAppUUID:appUUID userUUID:userUUID delegate:self];
}
// MARK: ProximityDelegate Callbacks.
- (void)nearbyUserFound:(NSString *)userUUID {
NSLog(@"userUUID found %@", userUUID);
[self.bridge.eventDispatcher sendDeviceEventWithName:@"nearByUserFound" body:@{@"userUUID":userUUID}];
}
@end
Issue Analytics
- State:
- Created 8 years ago
- Comments:52 (33 by maintainers)
Top Results From Across the Web
DeviceEventEmitter stops emitting events to application when ...
I wonder if this is related to "[Timer] React Events not fired if the device is locked and screen turned off"?
Read more >Detecting iPhone lock and unlock w… - Apple Developer
Hi,. Is there a way to detect iPhone lock and unlock events from an iOS application when the app itself is in the...
Read more >Screen Orientation - W3C
A screen can be in, or locked to, one of the following screen orientations : Any: The screen can be rotated by the...
Read more >State and Lifecycle - React
If the Clock component is ever removed from the DOM, React calls the componentWillUnmount() lifecycle method so the timer is stopped. Using State...
Read more >Why Javascript timer is unreliable, and how can you fix it
If you are a Javascript developer, at some point in your career, you must have used setTimeout or setInterval. They are extremely handy...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

here’s my current hacky workaround:
@nicklockwood agree with idea of
pauseInBackground. We should pause animations in the background, but it should make developers decide to pause timers(setTimeout and setInterval) or not.