DeviceEventEmitter listener not firing in detached app

Hi, great project! It would be awesome if Bluetooth beacons and geo fences would be implemented. I noticed it’s on the radar (iBeacon support).

I’ve did some testing where I created an Expo project and detached it with $ exp detach.

Then, I’ve installed $ npm install react-native-beacons-manager --save, ran $ react-native link and updated the build gradle as described here,

Note: You may have to update android/app/build.gradle after running react-native link. Change the line added by react-native link from compile project(’:library-name’) to compile(project(’:library-name’)) { exclude module: ‘react-native’ }.

In main.js I’ve added DeviceEventEmitter to the third line:

import { Platform, StatusBar, StyleSheet, View, DeviceEventEmitter } from 'react-native';

And below the imports I’ve added this code:

import Beacons from 'react-native-beacons-manager';

// Tells the library to detect iBeacons

// Monitoring
try {
  const myRegion = {
    identifier: 'BEACON',
    uuid: 'FDA50693-A4E2-4FB1-AFCF-C6EB07647825',
    minor: 54480,
    major: 10004


  console.log('Beacons monitoring started successfully');
} catch (err) {
  console.log('Beacons monitoring not started, error: ${err}');

DeviceEventEmitter.addListener('regionDidEnter', (region) => {
  console.log('regionDidEnter!', region);

DeviceEventEmitter.addListener('regionDidExit', (region) => {
  console.log('regionDidExit!', region);

All seems to work fine and I get the console.log Beacons monitoring started successfully, however, DeviceEventEmitter.addListener('regionDidEnter', ...); is never fired.

When I run the same code in a fresh non-Expo project (with react-native init) the listeners are triggered as expected. I understand detach is an alpha feature, so maybe it’s an issue or maybe I’m missing something :smiley:

Hm i’m not sure why that wouldn’t work. Is your code uploaded somewhere?

I’ve double checked by creating a blank project with the Expo XDE.

Added the android package to exp.json:

  "android": {
    "package": ""

Ran these commands with the CLI:

$ exp detach

$ npm install react-native-beacons-manager --save

$ react-native link

Updated android/app/build.gradle:


compile project(':react-native-beacons-manager')


compile(project(':react-native-beacons-manager')) { exclude module: 'react-native' }

Edited main.js:

Openend the project in Expo XDE and ran the app with $ react-native run-android in the CLI.

The monitoring starts according to console, but DeviceEventEmitter isn’t triggered. Same beacon with a non-Expo project works.

Thanks for the details! Can you upload both of those to Github? There are a bunch of small details that could be breaking this and it’ll be easier if I can just run the projects myself.

Got it:

It works fine btw with CRNA and npm run eject.

Forgot to add the working repo:

Great. I probably don’t have time to look at this today but maybe this weekend.

Hi there,

Just getting started with expo but it looks great. Wanted to follow up on this thread to see if there’s any progress on having beacon support through an SDK in expo, instead of having to eject the app and built it outside of expo. Thanks!

We recently released some changes to detach that should fix this. If you detach with SDK 16 it should work. Sorry for the delay @eugyev and @s3ms3m

Thank you for the update. We will likely use this soon.

I did have one question. Do you have plans to have an SDK that supports beacons without ejecting the app? My understanding is that once we eject we lose a lot of the benefits expo offers, including the code push and push notifications.

Thanks, I did some quick testing but ran into issues probably related to outdated versions. I will test in more detail when I have time.

We want to support beacons eventually but probably not in the next few months.