I am trying to get Firebase FCM to work in my React project (using webpack)
When trying to getToken () to use:
messaging.requestPermission()
.then(function() {
console.log('Notification permission granted.');
return messaging.getToken();
})
.then(function(token) {
console.log('token')
})
.catch(function(err) {
console.log('Unable to get permission to notify.', err);
});
An exception is thrown as follows:
browserErrorMessage: "Failed to register a ServiceWorker: The scrip
has an unsupported MIME type ('text/html')
I understand that this problem is related to the missing working user file: firebase-messaging-sw.js, which I added to the root of the project, but I still get the same error.
I'm not sure what I'm doing wrong here, I created a vanilla java script project and it works fine.
Any ideas on this issue?
source
share