You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Firefox中Firebase Web推送通知启用失败问题求助

Firebase Web Push Notifications Fail on Firefox with Service Worker Registration Error

我正在给网站集成Firebase的Web推送通知功能,在Chrome和Opera浏览器里都能正常运行,但在Mozilla Firefox里始终遇到问题——点击通知权限弹窗的“允许”后,会提示无法获取通知权限,具体的错误信息如下:

Object { code: "messaging/failed-serviceworker-regi…", message: "Messaging: We are unable to register service worker", name: "FirebaseError", browserErrorMessage: "ServiceWorker script at https://www ..", stack: "", 1 more… }

我测试了Firefox 54版本,也升级到最新的Firefox 57版本试过,结果完全一样。控制台的输出顺序也很奇怪:先打印Notification permission granted.,紧接着就抛出上面的错误。

下面是我使用的代码:

var config = { 
  apiKey: "myApiKey", 
  authDomain: "authDomain", 
  databaseURL: "databaseURL", 
  projectId: "projectId", 
  storageBucket: "storageBucket", 
  messagingSenderId: "mySenderId" 
}; 
// 请忽略config中的具体值
firebase.initializeApp(config); 
function requestPermission() { 
  console.log('Requesting permission...'); 
  // [START request_permission] 
  messaging.requestPermission() 
    .then(function () { 
      console.log('Notification permission granted.'); 
      return messaging.getToken(); 
    }) 
    .then(function (token) { 
      console.log(token); 
    }) 
    .catch(function (err) { 
      console.log('Unable to get permission to notify.', err); 
    }); 
}

有没有朋友遇到过类似的情况?或者能帮我排查下Firefox中Service Worker注册失败的原因?非常感谢!

内容的提问来源于stack exchange,提问作者jobin john

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 03:57:26