Firebase FCM React project issue - firebase-messaging-sw.js wrong type?

前端 未结 6 2073
没有蜡笔的小新
没有蜡笔的小新 2020-12-29 10:54

Im tryin to get Firebase FCM working in my React project(using webpack )

When trying to getToken() using:

 messaging.requestPermission()
  .then(func         


        
6条回答
  •  独厮守ぢ
    2020-12-29 11:16

    I have the same exact problem as in the original question, and I have gone through all kinds of solutions without any luck over the past 3 days. I am using ReactJS and Webpack. I've tried to include file called firebase-messaging-sw.js in my root folder, but it does nothing.

    Someone, please help, since the firebase notification is a much needed feature in the project I am developing...

    EDIT.

    I managed to solve the registration problem by installing a webpack plugin called sw-precache-webpack-plugin. This plugin autogenerates a service-worker file for you into your build directory.

提交回复
热议问题