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

127
Visualizações
sending notifications from service worker

I have a pwa app that basically is a simple form. If the network is offline, it is saved to local storage(indexedDB) and send afterwards when the connection is online. Up to here everything is ok, but I would like to show a message to the user 'the form was sent to the server' and I can't get it working. I use the property 'SYNC' for doing this feature. In my service worker the part of the code relative to this feature is:

self.addEventListener('sync', e => {
    console.log('SW: Sync');
    if ( e.tag === 'new-form' ) {

        // send to DB when onLine
        const resp = sendForm(); //up to here all is OK.

        self.registration.showNotification(' Succesfully send to MongoDB');// this line is not working

        e.waitUntil( resp);
    }
}); 

What could be wrong?, in javascript side, It is verified that Notification.permission === 'granted'.

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