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

712
Views
Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker for scope

FirebaseError: Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker for scope with script: ServiceWorker script evaluation failed (messaging/failed-service-worker-registration).

I get this error in production. In local chrome browser, it is perfectly working. I made sure that I stored firebase-messaging-sw.js file in public folder. What is wrong, any idea?

My firebase-messaging-sw.js file is as follows

'use strict';

importScripts("https://www.gstatic.com/firebasejs/9.6.3/firebase-app.js");
importScripts("https://www.gstatic.com/firebasejs/9.6.3/firebase-messaging.js");

const FIREBASE_CONFIG = {
    apiKey: "",
    authDomain: "",
    projectId: "",
    databaseURL: "",
    storageBucket: "",
    messagingSenderId: "",
    appId: "",
    measurementId: ""
};

// Initialize the firebase in the service worker.
firebase.initializeApp(FIREBASE_CONFIG);

self.addEventListener('push', function (event) {
    var data = event.data.json();

    const title = data.Title;
    data.Data.actions = data.Actions;
    const options = {
        description: data.description,
        data: data.Data
    };
    event.waitUntil(self.registration.showNotification(title, options));
});

self.addEventListener('notificationclick', function (event) { });

self.addEventListener('notificationclose', function (event) { });

messaging.onBackgroundMessage(function (payload) {
    console.log("Received background message ", payload);

    const notificationTitle = payload.notification.title;
    const notificationOptions = {
        description: payload.notification.description,
        icon: "/favicon-96x96.png",
    };

    // eslint-disable-next-line no-restricted-globals
    return self.registration.showNotification(
        notificationTitle,
        notificationOptions
    );
});
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!