Firebase推送通知在firefox 63中不起作用
我正在尝试实现FCM推送通知。我的firefox版本是63.0 下面是我的代码Firebase推送通知在firefox 63中不起作用,firebase,firefox,push-notification,firebase-cloud-messaging,service-worker,Firebase,Firefox,Push Notification,Firebase Cloud Messaging,Service Worker,我正在尝试实现FCM推送通知。我的firefox版本是63.0 下面是我的代码 var config = { apiKey: "${model.apiKey}", authDomain: "${model.authDomain}", databaseURL: "${model.databaseURL}", projectId: "${model.projectId}",
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);
});
已授予通知权限
正在控制台中显示。但是显示出一个错误
FirebaseError:消息传递:此浏览器不支持API的
需要使用firebase SDK。(消息/不支持的浏览器)
所以我拿不到代币。为什么会这样?请注意,我正在通过“http”运行我的应用程序。:
FCM SDK仅在通过HTTPS提供的页面中受支持。这是因为它使用了服务工作者,而服务工作者只能在HTTPS站点上使用。需要一个提供者吗?Firebase托管是在您自己的域上获得免费HTTPS托管的一种简单方法
在我的Firefox63中,当我试图通过http打开带有firebase初始化的页面时,我看到了与您类似的消息。
在这种情况下,我的Chrome会写下更明确的警告:
[弃用]通知API可能不再从不安全的来源使用。您应该考虑将应用程序切换到安全的原点,例如HTTPS.</P>
我在Firefox60上使用https时也看到了类似于您的消息。原因是“服务工作者”(但可以重新启用)。这条消息在Firefox中太笼统了