您的浏览器不支持 Firebase 消息传递如何解决? [英] Firebase messaging is not supported in your browser how to solve this?

查看:50
本文介绍了您的浏览器不支持 Firebase 消息传递如何解决?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 firebase 消息传递带有 react 的网络推送通知.但浏览器显示此消息

I am using firebase messaging for web push notification with react. But browser show this message

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

Messaging: This browser doesn't support the API's required to use the firebase SDK. (messaging/unsupported-browser)

这是代码:

const initializedFirebaseApp = firebase.initializeApp({
  apiKey: "XXXXXX",
  authDomain: "XXXXXXX",
  databaseURL: "XXXXXXXXX",
  projectId: "XXXXXX",
  storageBucket: "XXXX",
  messagingSenderId: "XXXXXX",
  appId: "XXXXXX"
});

if (firebase.messaging.isSupported()) {
    let messaging = initializedFirebaseApp.messaging();
}

firebase.messaging.isSupported() 总是返回 false.有什么办法可以继续吗?

firebase.messaging.isSupported() is always returning the false. Is there any way I should proceed?

react 版本:16.8.2 和 firebase 版本:6.0.2

Version for react : 16.8.2 and firebase version : 6.0.2

推荐答案

FCM 仅支持 localhost 和 https 启用的站点.如果您希望 FCM 支持,您需要在本地主机上工作或在某处部署(您可以使用 firebase).

FCM supports only in localhost and the https enabled sites only. if you want FCM to support you need to either work on localhost or deploy somewhere (you can use firebase).

如果您使用像 local.somehost.com 这样的 nginx 代理,则不支持云消息传递.要解决此问题,您需要将 local.somehost.com 设为 HTTPS,您可以在 nginx 中安装 openssl 和证书和密钥.

If you are using proxy using nginx like local.somehost.com cloud messaging doesn't support. To solve this you need to make your local.somehost.com as HTTPS you can install openssl and certificate and key in your nginx.

我认为这可以解决您的问题.

I think this solves your problem.

这篇关于您的浏览器不支持 Firebase 消息传递如何解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆