Search code examples
firefoxpush-notificationfirebase-cloud-messagingweb-push

How to Make FireFox recieve background push notification without loading page?


I am using FCM for web push notifications. All worked fine until suddenly Firefox stopped delivering push notifications except the page is open in the browser.

If the page is loaded and not in focus, notifications come in. I console.log()'d the onBackgroundMessage payload and I can confirm that the service worker receives it. But if I close that tab and send a push notification, it does not receive it.

The same setup works on Chrome, Opera, and Edge just fine no errors. Is there something with firefox?

Firefox version: 88.0.1 (64-bit) in my Service Worker I have:

messaging.onBackgroundMessage(function (payload) {

// Customize notification here
var action_label;
if('action_label' in payload.data){
    action_label = payload.data.action_label;
} else{
    action_label = "Details";
}

const notificationTitle = payload.data.title;
const notificationOptions = {
    body: payload.data.body,
    icon: payload.data.icon,
    requireInteraction: true,
    data: {
        click_action: payload.data.click_action,
        url:payload.data.click_action
    },
    actions: [
        {
            action: "open_url", title: action_label
        }
    ]
};

self.registration.showNotification(notificationTitle, notificationOptions);

});


Solution

  • This had to do with Firefox quitting instead closing, obtainable in MacBooks. Not a real technical issue.