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..."

Aperta
#575 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
firebase, javascript
Ambito
web-dev

Direzione di ricerca

Riproduci localmente il passaggio 11 in Chrome e analizza la registrazione di web-start\public\firebase-messaging-sw.js, raggiungibile all'indirizzo /firebase-messaging-sw.js. Confronta la configurazione di Firebase Messaging del codelab con il FirebaseError segnalato e verifica che il service worker predefinito venga registrato e che la console stampi un token del dispositivo FCM.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

codelab
[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:

image

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:

image

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

image

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! 🙏🙏🙏

Lingua principale
JavaScript
Stelle
1.9k
Fork
1.8k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di firebase/codelab-friendlychat-web

Tutte le issue di firebase/codelab-friendlychat-web

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.