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

307
Visualizações
How to make push notification open chrome app on click? (Node.js, Web-push)

Im using web-push to implement push notifications on my web app, im trying to figure out how to make chrome app open (or the browser they are using) when they click on it. So right now the best I could do was that onclick it will open a link which I dont like since it opens a new tab with the app and I start receiving duplicate notifications.

console.log("Service Worker Loaded...");
    var usuario
    self.addEventListener("push", e => {
        const data = e.data.json();
        usuario = data.usuario
    
        self.registration.showNotification(data.title, {
            icon: "/images/icon.png"
        });
    });
    
    self.addEventListener('notificationclick', function(event) {
        event.notification.close();
        event.waitUntil(self.clients.openWindow('https://fimsa-sistema-vales.herokuapp.com/vales/' + usuario));
    }, false);
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

i am also very new but i found this that could help try pasting this code

    self.addEventListener('notificationclick', function(event) {
    console.log('On notification click: ', event.notification.tag);
    event.notification.close();

    // This looks to see if the current is already open and
    // focuses if it is
    event.waitUntil(clients.matchAll({
        type: "window"
    }).then(function(clientList) {
        for (var i = 0; i < clientList.length; i++) {
            var client = clientList[i];
            if (client.url == '/' && 'focus' in client)
                return client.focus();
        }
        if (clients.openWindow)
            return clients.openWindow('/');
    }));

i got it from https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope/notificationclick_event``

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