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

216
Visualizações
Listening to "notificationclick" in browsing context

I have set up desktop notifications using:

Notification.requestPermission((result) => {
  if (result === "granted") {
    navigator.serviceWorker.register("/dummy.js").then((registration) => {
      registration.showNotification("Hello", {
        body: "Buzz! Buzz!",
        actions: [{...}],
      });
    });
  }
});

I can't use the Notification constructor, as I need to show buttons (actions) on the notifications, and for some reason the constructor doesn't support this.

I have no intention of firing or listening to the these notifications when the app is not open in a browser tab.

Is there a way to listen to the "notificationclick" and other notification related events from the main browsing context, and not from within the worker?

Alternatively is there any way to use the full set of features on the Notification constructor without having a worker?

To clarify further: I don't need the worker for anything other than using actions on the notifications. I only need to fire notifications / listen to notifications while the app is running in the browser, so I want to interact with the worker as little as possible. Writing logic for notification events in the worker itself is highly undesirable.

about 4 years ago · Santiago Trujillo
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