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アプリケーションのようなものです。
コードスニペットは次のとおりです。
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);
});
FirebaseメッセージングをサポートするNodeWebKitと呼ばれるフレームワークに移行する必要がありました。それを見てください。それは非常に単純で、電子に非常に似ています。残念ながら、electronはFirebaseメッセージングをサポートしていません。お役に立てれば!
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加