Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!