Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

120
Vistas
How to handle push notification on inactive site?

I have a PWA website that can send and receive push notifications when somebody makes a call on the site.

I am using Firebase Messaging for push notifications, here is some code:

notification:
    {
        title:"Video call!",
        body:"Video call from:"+m,
        click_action: "https://......netlify.app/?x="+m
    },
    data:
    {
        title:"Video call!",
        email:m,
        contact_link:"https://......netlify.app/?x="+m

I append some important parameters in the URL. The result: When the site is in focus, I receive the notification in the background the onMessage function of Firebase which I can handle. It works. When the site is closed, the click_action opens the site with the parameters, and it's also working. The only thing that does not work is when the site is inactive (another tab is in focus in the browser). The notification comes in, I click on the push-notification, the site becomes focused, but nothing changes, the site does not even reload. The URL parameters stay the same as before, they do not change to the one in the link.

So what can I do to make the inactive website change to the same site but with the parameters in the link?

My service worker does not do much, but here it is, in case it's needed for a solution:

firebase.initializeApp({
    ....
  });

  const messaging=firebase.messaging();

  messaging.setBackgroundMessageHandler(function (payload) {
    console.log(payload);
});
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Solved it by using onBackgroundMessage() in the service worker, which is exactly for situations like this.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda