How to avoid loading notifications bundle for web build?


I am using expo and react native web. I have integrated FCM for notifications for web but expo also loads a notifications bundle which I do not want.

The issue is when the notification is received in the browser and message is clicked, the app gets the focus but crashes saying “TypeError: _emitter is undefined”. This is on this line in src/Notifications/Notifications.ts:40

_emitter.emit('notification', notification);

So, it seems expo tries to use its Notifications module. Can I remove that for web build?

1 Like


The following solution works for me in web environment.

1. Install the following package:

npm install --save fbemitter

2. Update your code:

import * as Notifications from 'expo/build/Notifications/Notifications'

// By calling "Notifications.default.addListener()" function,
// the _emitter variable will be initialized correctly
Notifications.default.addListener(event => {
  console.log('message data',

// Now you should NOT need another one listener:
navigator.serviceWorker.addEventListener('message', event => {
  console.log('message data',

hi! this issue has been fixed in the most recent release- just install expo@39.0.4 to get the fix :+1:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.