FirebaseError: Mensajería: no podemos registrar el trabajador de servicio predeterminado. No se pudo registrar un ServiceWorker para el alcance con el script: la evaluación del script de ServiceWorker falló (mensajería/error en el registro del trabajador del servicio).
Me sale este error en producción. En el navegador Chrome local, funciona perfectamente. Me aseguré de almacenar el archivo firebase-messaging-sw.js en una carpeta pública. ¿Qué está mal, alguna idea?
Mi archivo firebase-messaging-sw.js es el siguiente
'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 ); });