【发布时间】:2022-06-17 01:02:53
【问题描述】:
我正在尝试从
导入脚本importScripts("https://www.gstatic.com/firebasejs/9.1.0/firebase-app.js");
importScripts("https://www.gstatic.com/firebasejs/9.1.0/firebase-messaging.js");
它用于 Firebase 云消息传递 (FCM),但不知道为什么 Angular 不喜欢在 ServiceWorker 上导入
它导入它(单击错误 URL 并获取脚本)但不知何故未能加载?
错误在这里:
Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'https://www.gstatic.com/firebasejs/9.1.0/firebase-app.js' failed to load.
at initInSw (http://localhost:4200/firebase-messaging-sw.js:35:1)
at http://localhost:4200/firebase-messaging-sw.js:56:1
angular.json
"assets": [
"src/favicon.ico",
"src/assets",
"src/manifest.json",
"src/firebase-messaging-sw.js"
],
index.html
<link rel="manifest" href="/manifest.json">
目录
尝试使用 fireship 的实现 https://www.youtube.com/watch?v=z27IroVNFLI&t=140s&ab_channel=Fireship 但也不起作用(相同的实现只是不同的 firebase 版本),我也认为与此无关
我的理论是我认为它真的没有加载,而我查看的是控制台请求? (因为文件名是(索引)在意味着它没有文件名因此不存在?)
【问题讨论】:
标签: angular firebase firebase-cloud-messaging angularfire