简体   繁体   中英

VueJS App and Firebase messaging error

Hi im trying to make push notifications work for my application but i cant seem to make it run with my Vue App

I keep getting this error:

Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker: The script has an unsupported MIME type ('text/html'). (messaging/failed-serviceworker-registration)

I dont know how to handle it.

This is my Main.js:

let config = {
 apiKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
 authDomain: 'vue-notify.firebaseapp.com',
 databaseURL: 'https://vue-notify.firebaseio.com',
 projectId: 'vue-notify',
 storageBucket: 'vue-notify.appspot.com',
 messagingSenderId: 'xxxxxxxxxxxxxxxxxxxxxx'
}

firebase.initializeApp(config)

This is the function in a component where I call the firebase.messaging()

subscribe () {
  firebase.messaging().requestPermission().then(() => firebase.messaging().getToken())
    .then((token) => console.log(token))
    .catch((err) => console.log(err))
}

Would be nice to know what i need to do

根据该文件 ,而这个答案这一个似乎你必须把在该配置firebase-messaging-sw.js在公共目录。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM