Firebase Web推送通知服务工作者问题 [英] Firebase web push notification Service worker issue

查看:47
本文介绍了Firebase Web推送通知服务工作者问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Web推送通知区域的新手.我想将Firebase Web通知从Web发送到Web.我尝试这样做,并最终遇到此错误

I am new to web push notification area. I want to send firebase web notifications from web to web. I tried doing that and ended up with this error

FirebaseError:消息传递:我们无法注册默认服务工作者.无法注册ServiceWorker:获取脚本时收到错误的HTTP响应代码(404).(消息/服务工作者注册失败)

FirebaseError: Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker: A bad HTTP response code (404) was received when fetching the script. (messaging/failed-serviceworker-registration)

我不知道我哪里出了错.在此先感谢

I dont know where am I went wrong. Thanks in Advance

推荐答案

最终得到了答案.

我们需要复制firebase-messaging-sw.js文件并将其保存在文件夹的根目录中.由于我使用了xampp,因此我将我的push文件夹推入了htdocs文件夹(/xampp/htdocs/push/),但是您需要确保firebase-messaging-sw.js应该位于localhost(/xampp)的根目录下/htdocs/).也就是说,当您在浏览器中搜索localhost/firebase-messaging-sw.js时,不应出现404错误.

We need to copy firebase-messaging-sw.js file and save it in the root of the folder. Since I used xampp, I ve push my push folder inside htdocs folder (/xampp/htdocs/push/), but you need to make sure that the firebase-messaging-sw.js should be in the root of the localhost(/xampp/htdocs/). i.e, when you search localhost/firebase-messaging-sw.js in browser, you shouldn't get a 404 error.

这篇关于Firebase Web推送通知服务工作者问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆