react-native-beacons-manager
react-native-beacons-manager copied to clipboard
regionDidEnter/regionDidExit not firing after kill the app
Version
1.1.0
Platform
iOS | Android
OS version
iOS 12
Steps to reproduce
- Kill the app
- Get closer / move away to the beacon
- The regionDidEnter / regionDidExit is fired in RNiBeacon but it happens before Javascript is loaded, so the listener added through:
Beacons.BeaconsEventEmitter.addListener('regionDidEnter', b => {
// code
});
doesn't get called.
I.E, [self sendEventWithName:@"regionDidEnter" body:event];
is sent before the listener is attached, so I miss the event.
It's important to kill the app in order to reproduce this issue.
Expected behavior
Receive the event in the listener.
Actual behavior
The event regionDidEnter / regionDidExit is not received
@ger86 I have the same problem but I also noticed that after the app was killed, my listeners were deleted. So even if I restart manually the app and trigger an event, [self sendEventWithName:@"regionDidEnter" body:event];
is sent but I get Sending "regionDidEnter" with no listeners registered.
Does it happens to you when restarting the app and triggering an event ?
Nop, it works fine in that case...Maybe you don't have the background modes enabled?
can you please tell me how to make listener working after app killed
@Najeisleem For me, the key point to fix this was that on iOS, when an event is triggered and the app is killed, the app is started, then the components are mounted. That s the moment when you should add again your listeners because, right after, the event is propagated to your listeners.
@cedrtang many thanks
For me, the app doesn't seem to do anything at all when its killed. I have it set to fire a local push notification on region enter, and it works great when the app is minimized or you're in a different app, but it won't do anything after killing the app entirely. I have background processing enabled (iOS) and i'm not removing listeners on componentWillUnmount either.
Is there a step I'm missing?
edit: I had "Uses Bluetooth LE accessories" enabled, but it seems like the secret sauce was to enable "Acts as a Bluetooth LE accessory" too.
Works now!