gpt4 book ai didi

Firebase 推送通知在 Firefox 63 中不起作用

转载 作者:行者123 更新时间:2023-12-05 03:04:25 31 4
gpt4 key购买 nike

我正在尝试实现 FCM 推送通知。我的 firefox 版本是 63.0。

下面是我的代码,

var config = {
apiKey: "${model.apiKey}",
authDomain: "${model.authDomain}",
databaseURL: "${model.databaseURL}",
projectId: "${model.projectId}",
storageBucket: "${model.storageBucket}",
messagingSenderId: "${model.messagingSenderId}"
};

firebase.initializeApp(config)
const messaging = firebase.messaging();
messaging.requestPermission().then(function () {
console.log("Notification permission granted.");
// get the token in the form of promise
return messaging.getToken()
}).then(function(token) {
$('#devicekey').val(token);
}).catch(function (err) {
console.log("Unable to get permission to notify.", err);
});

Notification permission granted

显示在控制台中。但是显示错误

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

这样我就拿不到token了,为什么会这样呢?请注意,我正在通过“http”运行我的应用程序。

最佳答案

firebase docs :

The FCM SDK is supported only in pages served over HTTPS. This is due to its use of service workers, which are available only on HTTPS sites. Need a provider? Firebase Hosting is an easy way to get free HTTPS hosting on your own domain.

在我的 Firefox 63 中,当我试图通过 http 打开一个带有 firebase 初始化的页面时,我看到了类似你的消息。在这种情况下,我的 Chrome 会写出更具体的警告:

[Deprecation] The Notification API may no longer be used from insecure origins. You should consider switching your application to a secure origin, such as HTTPS.

当我通过 https 在 Firefox 60 中工作时,我也看到了像你这样的消息。原因是“服务人员”disabled on Firefox 60 ESR (但可以重新启用)。此消息在 Firefox 中过于笼统。

关于Firebase 推送通知在 Firefox 63 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53041381/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com