Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

239
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda