3

I am trying to enable push notifications for a website using firebase. I am able to get it working perfectly in Google Chrome and Opera broswers. But I get the following error in mozilla firefox.

Unable to get permission to notify. Object { code: "messaging/failed-serviceworker-regi…", message: "Messaging: We are unable to register service worker", name: "FirebaseError", browserErrorMessage: "ServiceWorker script at https://www..", stack: "", 1 more… }

I am using firefox 54 for testing, also tried latest firefox 57 which shows the same error.

I get the popup to allow,block notifications when the page loads. When I click allow, I get the above error.

Below is the code I am using:

var config = {
  apiKey: "myApiKey",
  authDomain: "authDomain",
  databaseURL: "databaseURL",
  projectId: "projectId",
  storageBucket: "storageBucket",
  messagingSenderId: "mySenderId"
};

Please ignore the config values

firebase.initializeApp(config);

function requestPermission() {
  console.log('Requesting permission...');
  // [START request_permission]
  messaging.requestPermission()
    .then(function () {
      console.log('Notification permission granted.');
      return messaging.getToken();
    })
    .then(function (token) {
      console.log(token);

    })
    .catch(function (err) {
      console.log('Unable to get permission to notify.', err);
    });

I also get the log 'Notification permission granted, and below that I get the above error

Any help will be appreciated, Thanks.

jobin john
  • 53
  • 7
  • Does this answer your question? [Firebase Service worker not found while using GWT (404 Error)](https://stackoverflow.com/questions/40673265/firebase-service-worker-not-found-while-using-gwt-404-error) – santamanno Apr 10 '20 at 18:49

0 Answers0