Are You Required To Register You Fireram?
Firebase FCM React Project issue: Failed to register a ServiceWorker
Those who are using "create-react-app" to build a react project and trying to integrate FCM must have encountered following type of errors:
browserErrorMessage: "Failed to register a ServiceWorker: The scrip
has an unsupported MIME type ('text/html')
or an fault like 'service worker script evaluation failed'
Hither'due south a simple solution to it my friends!
You lot tin create the 'firebase-messaging-sw.js' file inside public folder and add the following snippet in it.
if ('serviceWorker' in navigator) {
navigator.serviceWorker.annals('../firebase-messaging-sw.js')
.and so(office(registration) {
panel.log('Registration successful, scope is:', registration.scope);
}).grab(role(err) {
console.log('Service worker registration failed, mistake:', err);
});
}
That'southward information technology folks. Your FirebaseError should be gone past now…
Source: https://medium.com/practical-code-labs/firebase-fcm-react-project-issue-failed-to-register-a-serviceworker-b9c5573caffa
Posted by: watlingtonthestive.blogspot.com
0 Response to "Are You Required To Register You Fireram?"
Post a Comment