react-native: [Timer] React Events not fired if the device is locked and screen turned off.
If 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
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 52 (33 by maintainers)
here’s my current hacky workaround: