JavaScript Firefox not opening window in service worker for Push message firefox window opening off screen,firefox opening small window,firefox

Firebase Cloud Messaging

I have everything setup, the Push messages are received fine and when I click on it, it opens new window... but only in Chrome, in Firefox it is not opened.

I have specifically allowed popups, but didn't make any difference.

I was just debugging for 1 hour

self.addEventListener('notificationclick', function(e) {
    console.log("This is printed to console fine");
    clients.openWindow('https://example.com'); // this makes no error, nothing
});

Any ideas?

Works in Firefox 47.0

Doesn't work in Firefox Quantum 60

Subscribed a bug.

Answer:1

I also struggled with this for a while...

To anyone else having the problem, I wanted to add something:

You can still use firebase.messaging() but you have to make sure you put it AFTER the event listener.

To make this clear:

This does NOT work (clients.openWindow does nothing):

const messaging = firebase.messaging();

// Add an event listener to handle notification clicks
self.addEventListener('notificationclick', function (event) {
    if (event.action === 'close') {
        event.notification.close();
    } else if (event.notification.data.target_url && '' !== event.notification.data.target_url.trim()) {
        clients.openWindow(event.notification.data.target_url);
    }
});

messaging.setBackgroundMessageHandler(function (payload) {
    // ... add custom notification handling ...
});

This does work (clients.openWindow opens link as expected):

// Add an event listener to handle notification clicks
self.addEventListener('notificationclick', function (event) {
    if (event.action === 'close') {
        event.notification.close();
    } else if (event.notification.data.target_url && '' !== event.notification.data.target_url.trim()) {
        clients.openWindow(event.notification.data.target_url);
    }
});

const messaging = firebase.messaging();

messaging.setBackgroundMessageHandler(function (payload) {
    // ... add custom notification handling ...
});

Still not sure of the underlying reason. I also suspect that the messaging() messes up the click event and makes Firefox refuse to open a window because it considers that the user took no direct action at the notification.

But at least I have a workaround and can keep going.

Hope that helps.

Answer:2

Why is my algorithm returning “-1” meaning that target value 73 isn’t in the array? (When clearly 73 is in the array). [this is from Khan Academy, but isn't helping] It's supposed to return either ...

Why is my algorithm returning “-1” meaning that target value 73 isn’t in the array? (When clearly 73 is in the array). [this is from Khan Academy, but isn't helping] It's supposed to return either ...

  1. canvas
  2. canada
  3. cancelled
  4. canceled vs cancelled
  5. cancun
  6. canada goose
  7. cane corso
  8. canes
  9. canadian prime minister
  10. cancun flights
  11. canker sore
  12. candy
  13. cancer
  14. canon
  15. canvas prints
  16. cancer sign
  17. candace owens
  18. canada news
  19. candytopia
  20. canlis

import React, { Component } from 'react' import Head from './Head' import Popular from './Popular' import Movie from './Movie' import Search from './Search' class Flix extends Component { ...

import React, { Component } from 'react' import Head from './Head' import Popular from './Popular' import Movie from './Movie' import Search from './Search' class Flix extends Component { ...

  1. move components between layers sketchup
  2. eagle move components between sheets
  3. jira move components between projects
  4. angular move data between components
  5. rtc move files between components

how do I connect the button (which is in HTML page) to connect to php url, once the ON/OFF button is clicked. the code basically have to call the php once the button is clicked and when the php is ...

how do I connect the button (which is in HTML page) to connect to php url, once the ON/OFF button is clicked. the code basically have to call the php once the button is clicked and when the php is ...

  1. link html button to javascript function
  2. link html button to python function
  3. link html button to another page
  4. link html button to javascript
  5. link html button to php page
  6. link html button to php function
  7. link html button
  8. link html button to page
  9. link html button send
  10. html link button code
  11. html link button style
  12. link button html w3schools
  13. link button html css
  14. link button html bootstrap
  15. html link button generator
  16. html link button with image and text
  17. html link button to form
  18. html link button to new page
  19. html link button new tab
  20. html link button tag

When dynamically changing content within a div is there a way of delaying the display of the new content until all layout is complete? I am using javascript and ajax to update the contents of a div ...

When dynamically changing content within a div is there a way of delaying the display of the new content until all layout is complete? I am using javascript and ajax to update the contents of a div ...