firebase / quickstart-js

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

Getting errors while developing firebase-cloud-messaging app #617

Open akash07k opened 3 years ago

akash07k commented 3 years ago

Step 1: Describe your environment

Step 2: Describe the problem:

Steps to reproduce:




Observed Results:

Expected Results:

Relevant Code:

  // TODO(you): code here to reproduce the problem

So I'm developing a firebase cloud messaging app and getting some issues. I solved most of the issues by myself but still unable to find the solutions of some problems. The problem here is that I'm using SDK V9 and the code in this repo is not using the moduler code. Instead of it, still the old styled code is being used (compat) one and hence it is creating a lot of problem for new comers. My code is in below repo: https://github.com/firebase/quickstart-js And the first issue which I'm having is: FirebaseError: Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker for scope ('http://localhost:3000/firebase-cloud-messaging-push-scope') with script ('http://localhost:3000/firebase-messaging-sw.js'): ServiceWorker script evaluation failed (messaging/failed-service-worker-registration). at registerDefaultSw (registerDefaultSw.ts:43) at async updateSwReg (updateSwReg.ts:28) at async getToken$1 (getToken.ts:43)

iamnoufal commented 3 years ago

you should create a firebase-messaging-sw.js in root

Feroz-Istar commented 2 years ago

It would be great if you please provide some sample code for firebase messaging as well.

iamnoufal commented 2 years ago

It would be great if you please provide some sample code for firebase messaging as well.

I've done a firebase cloud messaging model. Do visit my repo https://github.com/Rahman24/fcm-example for a code model

sebastam97 commented 2 years ago

I have the same error when I go to version 9 and I don't know how to fix it, I followed the steps in the documentation and nothing i needed help

iamnoufal commented 2 years ago

I have the same error when I go to version 9 and I don't know how to fix it, I followed the steps in the documentation and nothing i needed help

What is you problem? Please explain it briefly