【发布时间】:2017-10-03 23:01:04
【问题描述】:
尝试在 firebase 中检索令牌时出现以下错误:
code: "messaging/unsupported-browser"
message: "Messaging: This browser doesn't support the API's required to use the firebase SDK. (messaging/unsupported-browser)."
stack: "FirebaseError: Messaging: This browser doesn't support the API's required to use the firebase SDK. (messaging/unsupported-browser).
有没有办法解决这个问题?我希望能够在我的 android 设备和这个应用程序之间创建一个消息传递系统。有点像 slack 应用程序。
这是一个代码sn-p:
importScripts('https://www.gstatic.com/firebasejs/4.5.0/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/4.5.0/firebase-messaging.js');
// Initialize Firebase
var config = {
apiKey: "myapikey",
authDomain: "myauthdomain",
databaseURL: "databaseurl",
projectId: "projectid",
storageBucket: "storagebucket",
messagingSenderId: "senderID"
};
firebase.initializeApp(config);
const messaging = firebase.messaging();
messaging.requestPermission()
.then(function() {
console.log('Notification permission granted.');
})
.catch(function(err) {
console.log('Unable to get permission to notify.', err);
});
messaging.getToken()
.then(function(currentToken) {
if (currentToken)
console.log(currentToken);
})
.catch(function(err) {
console.log('An error occurred while retrieving token. ', err);
});
【问题讨论】:
-
这个没有更新吗?
-
我会添加一个答案
标签: javascript firebase electron firebase-cloud-messaging