Firebase云消息传递无法在Mozilla firefox隐身模式下运行

时间:2018-05-23 11:08:08

标签: firebase firebase-cloud-messaging

Firebase云消息在mozilla中正常运行,但当我在隐身模式下尝试相同时,此错误会导致应用崩溃。

此浏览器不支持使用firebase SDK所需的API。 (消息/不支持的浏览器)mozilla

无论如何,我们可以通过它来处理这个问题。

1 个答案:

答案 0 :(得分:-1)

"在Firefox中,Service Worker API被隐藏,当用户处于隐私浏览模式时无法使用。"

来源:https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers

您无法在Firefox的私有模式下使用Messaging,因为它依赖于Service Worker API。没有办法绕过这个。

您可以通过调用messaging.isSupported()来检查是否支持消息传递。示例代码:

import firebase from 'firebase/app';
import 'firebase/messaging';

if (firebase.messaging.isSupported()) {
  // messaging is supported
  const messaging = firebase.messaging();
} else {
  // messaging is not supported
}