I am trying to write a console.log statement for the firebase service worker that lives in the public folder of the react app I am working with. Is this possible?
firebase-messaging-sw.js
importScripts('https://www.gstatic.com/firebasejs/7.24.0/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/7.24.0/firebase-messaging.js');
console.log("is service working working")
firebase.initializeApp({
apiKey: "someapikey",
authDomain: "somedomain",
databaseURL: "somedburl",
projectId: "someprojectid",
storageBucket: "somestoragebucket",
messagingSenderId: "someMessageId",
appId: "someAppId"
});
const messaging = firebase.messaging();
My service worker was not running during this time, causing the service worker not to load. If anyone else has this problem make sure you load your firebase-massaging service worker file through importScripts with your current running service worker. In this example I assumed that firebase-messaging-sw.js would run but it did not and I had to import it through google workbox which runs the applications current service worker
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.