Thursday, 3 September 2020

Firebase messaging warning messages on service worker install process

I'm using firebase for push web notifications, my file firebase-messaging-ws.js is something like this:


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

    
fetch('./firebase-data.json')
.then(r => r.json())
.then(fbData => {
    let app = firebase.initializeApp(fbData);    
    firebase.messaging(app);
    console.log('Firebase Service Worker loaded for projectId:', fbData.projectId);
}).catch(err => {
    console.error('Error configuring firebase messaging: ', err)
});

I'm using a json file, firebase-data.json to load the firebase configuration data and It works, I can receive push notifications, however several log warnings appear in the console when I call to firebase.messaging(), If I use a local object (without fetch() command) then all works OK and there is no warning messages.

The log messages are like Event handler of 'XXX' event must be added on the initial evaluation of worker script.: enter image description here

Can I avoid the warning messages when I use an external file to load the firebase configuration data ?



from Firebase messaging warning messages on service worker install process

No comments:

Post a Comment