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

241
Vistas
How to handle Firebase push notification when site is already open?

I have a PWA that sends a notification to people when they are being called. It only works when the PWA isn't open, or the site isn't in focus. How can I still receive the notification in the app/site even if it's already in focus? I want the PWA to notice that it received a push-notification even if it's already open, perhaps handle things differently in that case.

I have this code for sending the notification:

function sendNotification(){
    const toSend ={
        notification:
        {
            title:"Video Call!",
            body:"Video call!",
            click_action: "https://....netlify.app/?x="+m,
            sound: "default",
            vibrate: [200, 100, 200, 100, 200, 100, 200]
        },
        to:othermailandtoken[1] 
        };
        
        const jsonString = JSON.stringify(toSend);
        
        
      var xhr = new XMLHttpRequest();
      xhr.open('POST', 'https://fcm.googleapis.com/fcm/send', true);
        xhr.onload = function(){
        console.log("google response: ",this.responseText);
        }
        
      xhr.setRequestHeader("Content-type", "application/json");
      xhr.setRequestHeader("Authorization","key=....");
    xhr.send(jsonString);
}
about 4 years ago · Juan Pablo Isaza
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