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

119
Visualizações
Service worker not in navigator

I am trying to get a service worker to be able to subscribe for notifications as well as send push notifications. To do this I am registering a service worker (one shows in the Chrome console) and then trying to do my task there. So far I can register a service worker but it will not show in the navigator like a bunch of guides said it should. Below is my current code stripped down to a minimum test case. I am doing this in Vue.js as my front end framework.

Register

import { register } from 'register-service-worker'
  console.log('Registering service worker')
  register(`service-worker.js`, {scope: '/'},{
    ready () {
      console.log('Service worker is ready.')
    },
    registered () {
      console.log('Service worker has been registered.')
    },
    error (error) {
      console.error('Error during service worker registration:', error)
    }
  })

serviceworker file

console.log(navigator) // This is where I am manually checking for serviceWorker to exist

if ('serviceWorker' in navigator) {
    navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) {
        console.log("SW Registered pre push manager")
    })
}

I have researched google and SO and all that points to is that I need https except on localhost (which I am on) and that I need to make sure the scope is correct, both are good there.

My question is how can I get this to work where the code inside my if statement will run

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