Nickersoft / push-fcm-plugin

Official Firebase Cloud Messaging plugin for Push.js v1.0 :fire:
https://pushjs.org
42 stars 13 forks source link

initial evaluation of worker script console messages #3

Closed ellisio closed 6 years ago

ellisio commented 6 years ago

Hello,

When using this and registering FCM via VueJS I get the following warning messages in Chrome's console on initial loading of the service worker:

Event handler of 'push' event must be added on the initial evaluation of worker script.
t @ firebase-messaging.js:1766
e.INTERNAL.registerService.Messaging @ firebase-messaging.js:1766
value @ firebase-app.js:1825
h.(anonymous function) @ firebase-app.js:1825
s @ firebase-app.js:1825
(anonymous) @ firebase-messaging-sw.min.js:1
firebase-messaging.js:1766 Event handler of 'pushsubscriptionchange' event must be added on the initial evaluation of worker script.
t @ firebase-messaging.js:1766
e.INTERNAL.registerService.Messaging @ firebase-messaging.js:1766
value @ firebase-app.js:1825
h.(anonymous function) @ firebase-app.js:1825
s @ firebase-app.js:1825
(anonymous) @ firebase-messaging-sw.min.js:1
firebase-messaging.js:1766 Event handler of 'notificationclick' event must be added on the initial evaluation of worker script.

This appears to be a warning spit out by the following line in the Service Worker:

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

Any idea why these are being thrown?

Nickersoft commented 6 years ago

After scraping my mind trying to remember, I defaulted to looking up this warning to refresh my memory. This warning cropped up a lot during development and is caused by the fact Firebase is being initialized inside an event listener callback. Unfortunately, this is required in order to pass config options from the client to the service worker and I think there's little that can be done to fix it. The good news is, this is just a warning. It shouldn't prevent the plugin from functioning properly.

ellisio commented 6 years ago

Sounds good, I just know I have QA and Product folks who see anything yellow or red in the console and flip out and fail PRs for it. I'll let everyone know... haha.

Nickersoft commented 6 years ago

Haha yeah, it's all good man. I would have definitely done something about it if I thought I could. The whole point was to have a single config without needing to duplicate the config in the ServiceWorker. In order to make it more streamlined for the end user, the console had to take a quit. Let me know if you run into any other problems :)