简体   繁体   English

生产中的 Firebase 消息传递

[英]Firebase messaging in production

I have a project that works with FCM.我有一个与 FCM 一起使用的项目。 On the localhost, every thing works fine and I get the token for FCM;在本地主机上,一切正常,我得到了 FCM 的令牌; but, in production, I get this error:但是,在生产中,我收到此错误:

FirebaseError: Messaging: We are unable to register the default service worker. FirebaseError: Messaging: 我们无法注册默认的 Service Worker。 Failed to register a ServiceWorker for scope ('https://myxdomain.com/firebase-cloud-messaging-push-scope') with script ('https://myxdomain/firebase-messaging-sw.js'): A bad HTTP response code (403) was received when fetching the script.无法使用脚本 ('https://myxdomain/firebase-messaging-sw.js') 为作用域 ('https://myxdomain.com/firebase-cloud-messaging-push-scope') 注册 ServiceWorker: 不好获取脚本时收到 HTTP 响应代码 (403)。 (messaging/failed-service-worker-registration). (消息/失败的服务工作人员注册)。

I'm deploying my app in an Apache server.我正在 Apache 服务器中部署我的应用程序。

As mentioned here , you need to add firebase-messaging-sw.js file in correct folder.正如这里提到的,您需要在正确的文件夹中添加firebase-messaging-sw.js文件。 It may be something like this: /var/www/...它可能是这样的: /var/www/...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM