firebase / firebase/firebase-js-sdk

Cloud Messaging doesn't work in Firefox for Android

Open
#5,165 7 comments 2 reactions 0 assignees View on GitHub
api: messaging browser-compatibility-issue bug
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:
![image](https://user-images.githubusercontent.com/8019593/125985438-eda3ffaf-175f-4d1a-bf3c-25285cb5812a.png)

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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.