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

158
Visualizações
Firebase Push notifications stopped to work in NuxtJS

again I have some troubles with Push notifications

The same code worked a few weeks ago. Yesterday I accidentally noticed that push notifications are not working anymore. I'm doing the same as written in the documentation.

I use NuxtJS without @nuxtjs/messaging because it doesn't support the latest Firebase version.

Here is my code for "firebase-messaging-sw.js":

importScripts('https://www.gstatic.com/firebasejs/8.10.0/firebase-app.js')
importScripts('https://www.gstatic.com/firebasejs/8.10.0/firebase-messaging.js')
// Initialize the Firebase app in the service worker by passing in
// your app's Firebase config object.
// https://firebase.google.com/docs/web/setup#config-object
firebase.initializeApp({
  apiKey: '###',
  authDomain: '###',
  databaseURL: '###',
  projectId: '###',
  storageBucket: '###',
  messagingSenderId: '###',
  appId: '###',
  measurementId: '###',
})

// Retrieve an instance of Firebase Messaging so that it can handle background
// messages.
const messaging = firebase.messaging()
let pushUrl = ''
messaging.onBackgroundMessage((payload) => {
  console.log('Received background message ', payload)
  // Customize notification here
  const notificationTitle = payload.data.title
  const notificationOptions = {
    body: payload.data.body,
    url: payload.data.url,
    link: payload.data.url,
    icon: './icon-for-push.png',
  }

  pushUrl = payload.data.url

  self.registration.showNotification(notificationTitle, notificationOptions)
})

self.addEventListener('notificationclick', (e) => {
  e.notification.close()
  return self.clients.openWindow(pushUrl)
})

On the server side everything is okay: enter image description here

Update 1 First time everything works time, problems occurs after X time. When I manually registered / unregistered service workers it started to work again

Update 2 I started a diary to catch a moment when problem occurs, then I noticed that push notifications stops to work after every deploy

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