FirebaseError - messaging/failed-serviceworker-registration

烈酒焚心 提交于 2019-12-11 12:46:05

问题


Okey here is the deal, I have asked a couple of firebase related question already in Stackoverflow, and even without any answers I managed to get firebase working, and received a bunch of notifications. I really don't know what I did to make it work, it was a combination of lots of things.

(Related issues posted earlier: How to include firebase cloud messaging into ReactJS project using webpack | Firebase FCM with ReactJS and Webpack not working: We are unable to register the default service worker)

Anyhow, now it is not working again. I tried to simplify some configurations etc. and I broke the service-worker.

Now when I am trying to register the default firebase service-worker, I get the following error. When I type localhost:8000/firebase-messsaging-sw.js into my address bar, the file opens up though.

The thing that mystifies me is that "window is not defined error" since I have no idea why it is giving that. When I open up the file where it is coming from, I get this line of code:

Notice that I have the firebase-messaging-sw.js file running as a worker there, and opening that file opens a bunch of code, so something is registered by firebase.

WHAT I AM ASKING IS: How do I get rid of these firebase/messaging cannot register the default service worker errors, and that window is not defined error, and get FCM running stable?


回答1:


I managed to solve my problem (again without any answers..). I needed to downgrade webpack-dev-server from 2.11.1 to 2.11.0! I am hoping that this might help someone else having this issue.



来源:https://stackoverflow.com/questions/48657131/firebaseerror-messaging-failed-serviceworker-registration

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!