[英]Is there a way to do a console.log from the firebase-messaging-sw with firebase cloud messaging
我正在尝试为 firebase 服务工作者编写一个 console.log 语句,它位于我正在使用的 React 应用程序的公共文件夹中。 这可能吗?
firebase-messaging-sw.js
importScripts('https://www.gstatic.com/firebasejs/7.24.0/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/7.24.0/firebase-messaging.js');
console.log("is service working working")
firebase.initializeApp({
apiKey: "someapikey",
authDomain: "somedomain",
databaseURL: "somedburl",
projectId: "someprojectid",
storageBucket: "somestoragebucket",
messagingSenderId: "someMessageId",
appId: "someAppId"
});
const messaging = firebase.messaging();
这段时间我的service worker没有运行,导致service worker没有加载。 如果其他人遇到此问题,请确保您通过 importScripts 使用当前正在运行的服务工作者加载您的 firebase-massaging 服务工作者文件。 在这个例子中,我假设 firebase-messaging-sw.js 会运行,但它没有运行,我不得不通过运行应用程序当前服务工作者的谷歌工作箱导入它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.