firebase / quickstart-js

Firebase Quickstart Samples for Web
https://firebase.google.com
Apache License 2.0
5.14k stars 3.67k forks source link

Messaging example does not works #812

Open emremutlu08 opened 4 months ago

emremutlu08 commented 4 months ago

Step 1: Describe your environment

Operating system: MacOS Browser: Safari/Chrome Firebase SDK version: 10.1.0

Step 2: Describe the problem:

I already gave the permissions however the ui is still asking for permissions. In the browser console, it says: "An error occurred while retrieving token. FirebaseError: Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker for scope ('http://localhost:5173/firebase-cloud-messaging-push-scope') with script ('http://localhost:5173/firebase-messaging-sw.js'): ServiceWorker script evaluation failed (messaging/failed-service-worker-registration). "

Screenshot 2024-07-19 at 11 03 46

Steps to reproduce:

  1. git clone https://github.com/firebase/quickstart-js
  2. cd messaging/
  3. fill config.ts
  4. npm install -g firebase-tools
  5. firebase login
  6. firebase use --add
  7. npm install
  8. firebase emulators:start
  9. npm run dev

Observed Results:

Expected Results:

bunniesnu commented 3 months ago

Did you fix it? Stuck with the same problem. I would like to know the solution.

0wwafa commented 2 months ago

same here! I need a f*ing working example! everything worked until 2 weeks ago.. now nothing works and the examples don't work too!

mgszy commented 2 months ago

Any update on this? Just came across this issue myself.

mgszy commented 2 months ago

For anyone else having this problem, I found a workaround. If I follow the steps provided under the "Running the app using the Firebase CLI" header in the readme.md then it generates the registration token.

It is also worth noting the examples given to send a message use the legacy approach and should be updated to the newer suggested way to push.