Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloud Messaging doesn't work in Firefox for Android #5165

Open
danieloliveira117 opened this issue Jul 16, 2021 · 7 comments
Open

Cloud Messaging doesn't work in Firefox for Android #5165

danieloliveira117 opened this issue Jul 16, 2021 · 7 comments

Comments

@danieloliveira117
Copy link

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

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:

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
    );
});
@google-oss-bot
Copy link
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@looptheloop88
Copy link

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.

@danieloliveira117
Copy link
Author

danieloliveira117 commented Jul 19, 2021

@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)

Quoting MDN:

From Firefox 72 onwards, can only be called in response to a user gesture such as a click event.

@looptheloop88
Copy link

looptheloop88 commented Jul 19, 2021

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.

@looptheloop88
Copy link

Probably related to this Stack Overflow post.

@danieloliveira117
Copy link
Author

@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.

@jahooma
Copy link

jahooma commented Sep 20, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants