firebase / firebase/codelab-friendlychat-web
Step #11 Error: "Unable to get messaging token. FirebaseError: Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker for scope..."
- Dominant language
- JavaScript
- Stars
- 1.9k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
### [REQUIRED] Codelab info
https://codelabs.developers.google.com/codelabs/firebase-web/#10
I encountered this problem on **"Step 11. Show notifications"**
### [REQUIRED] Project setup
As instructed, I've created `firebase-messaging-sw.js` in `web-start\public`. Ie. Loading this works for me:
`http://localhost:5000/firebase-messaging-sw.js`
I am working on localhost in `Chrome Version 87.0.4280.88 (Official Build) (64-bit)`.
### [REQUIRED] Describe the problem
On Step 11, I am currently on the step: **"Get your device token."** But after I refresh my browser (Chrome) and allow notifications, I am getting this error in the console:

Per the codelab tutorial, after clicking "Allow" (notifications in the browser), I was expecting in my console:
`4. Open the JavaScript console of your browser. You should see the following message: Got FCM device token: cWL6w:APA91bHP...4jDPL_A-wPP06GJp1OuekTaTZI5K2Tu`
## What I've tried:
I saw there was a previous closed issue: https://github.com/firebase/codelab-friendlychat-web/issues/208
I've tried copying my firebaseConfig var and manually initializing it again but it didn't work for me. Ie. This _**didn't**_ work for me:

PS. Obviously, I went to my Firebase project console and copied over my actual project parameters. Ie. The javascript object given under:

The only other change was in the codelab, in `firebase-messaging-sw.js` the firebase versions were hardcoded to `6.0.4` but I went ahead and updated those to `8.2.2`.
### [Optional] Suggested fix
Unsure. Please help. Thank you! Everything else in the codelab was terrific so far. I know I'm a decade late to Firebase but this is amazing! Thank you for putting it together! 🙏🙏🙏
Contributor guide
Assessment
This issue has not been assessed yet.