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

126
Visualizações
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 Respostas
Responde à pergunta

0

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

about 4 years ago · Juan Pablo Isaza Relatório
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