firebase / firebase/firebase-js-sdk
Cloud Messaging doesn't work in Firefox for Android
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 37
Description
### 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:
1. Attempt to get messaging token in Firefox for Android.
#### Relevant Code:
Main app:
```javascript
const firebaseApp = firebase.initializeApp({...});
const messaging = firebaseApp.messaging();
const currentToken = await messaging.getToken({
vapidKey: '...',
});
```
firebase-messaging-sw.js:
```javascript
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
);
});
```
Contributor guide
Assessment
This issue has not been assessed yet.