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

Abierto
#575 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
firebase, javascript
Área
web-dev

Línea de trabajo

Reproduce localmente el paso 11 en Chrome e inspecciona el registro de web-start\public\firebase-messaging-sw.js, que está disponible en /firebase-messaging-sw.js. Compara la configuración de Firebase Messaging del codelab con el FirebaseError notificado y verifica que el service worker predeterminado se registre y que la consola muestre un token de dispositivo FCM.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
JavaScript
Estrellas
1.9k
Forks
1.8k
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de firebase/codelab-friendlychat-web

Todos los issues de firebase/codelab-friendlychat-web

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.