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

101
Visualizações
Firebase messaging for web. Multiple tabs notifications

I'm using Firebase Messaging for browser notifications. Problem is when multiple tabs are open. Notification for every tab is shown. Adding tag to options didn't help

firebase.initializeApp(constants.CONFIG); 
const messaging = firebase.messaging();

messaging.setBackgroundMessageHandler(({ data }) => { 
  const options = { 
    body: data.body, 
    data: { link: data.link, }, 
    icon: data.icon, 
  };

  const backgroundNotification = self.registration.showNotification(data.title, options);

  return backgroundNotification; 
});

I need only one notification to be displayed even when many tabs with same app are open

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Comment this line of code

  const backgroundNotification = self.registration.showNotification(data.title, options);

and use instead

                new Notification(notification.title, {
                body : notification.body,
                tag : notification.title,
                icon : notification.icon
            });
  • Note that - Tag is unique, If you have 2 tabs and you are sending a push with name title: title1 and title1, it will show the push only ones.

Example 3.5: https://notifications.spec.whatwg.org/

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