Cloud Messaging doesn't work in Firefox for Android
Describe your environment
- Operating System version: Android 11
- Browser version: Firefox for Android 90.1.1
- Firebase SDK version: 8.7.1
- Firebase Product: Cloud Messaging
Describe the problem
In Firefox for Android when trying to get the messaging token it crashes with the following error:

The same code is functional in Chrome (Android, Windows, Ubuntu), Firefox (Windows, Ubuntu) and Edge (Windows).
Steps to reproduce:
- Attempt to get messaging token in Firefox for Android.
Relevant Code:
Main app:
const firebaseApp = firebase.initializeApp({...});
const messaging = firebaseApp.messaging();
const currentToken = await messaging.getToken({
vapidKey: '...',
});
firebase-messaging-sw.js:
importScripts('https://www.gstatic.com/firebasejs/8.6.1/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/8.6.1/firebase-messaging.js');
firebase.initializeApp({...});
const messaging = firebase.messaging();
messaging.onBackgroundMessage((payload) => {
console.log(
'[firebase-messaging-sw.js] Received background message ',
payload
);
});
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
Hi @danieloliveira117, thanks for the report. I was able to replicate the issue. I noticed that the dialog box or prompt asking for notification permission is missing in the Mozilla Firefox browser app on an Android device.
I'm not really sure if this is a bug in the JS FCM SDK or in the Mozilla Firefox browser app. Let me check and update this thread if I have any information to share.
@looptheloop88 I forgot to add in the code above, but in Firefox it only shows the permission request if it originates from a user interaction (eg: click)
From Firefox 72 onwards, can only be called in response to a user gesture such as a click event.
Thanks for the additional information @danieloliveira117. I tried pasting the URL of my test app in the Notes app and clicked it, but the only prompt I got was the "Open with" available browsers.
Probably related to this Stack Overflow post.
@looptheloop88 I'm not 100% if its the same issue, but by doing a factory reset of the app. I was able to get the token/receive notifications correctly.
This is affecting us. If the user sets Firefox set as their default browser, our PWA web app (actually a TWA android app) fails to receive any browser push notifications.