How to get gcm_sender_id for website in Firebase
Solution 1
The sender ID that you enter in the manifest.json of your web app is independent of your Firebase project. It is the same for all web apps (yours, mine, everybody's):
"gcm_sender_id": "103953800507"
So just copy/paste the line above into the manifest.json for your project. See this section of the FCM documentation.
Solution 2
Seems like Firebase Messaging actually works even if you skip this step. Look at https://web-push-demo-11213.firebaseapp.com as an example.
This demo website doesn't even have a manifest but is able to talk to FCM, get tokens, refresh them and so on.. Sorry you won't be able to actually send a push though since you don't know the auth key, but you get the idea - I've tested it, it works.
In light of this, not sure why this manifest requirement though.
Also, looking at the FCM SDK source on github, looks like they only throw an error if you have a manifest with a gcm_sender_id
that's not 103953800507
. For everything else (the gcm_sender_id
field in manifest missing, or even the manifest itself missing from the website), it works as fine.
See the code here: https://github.com/firebase/firebase-js-sdk/blob/master/packages/messaging/src/controllers/window-controller.ts#L329-L355
Solution 3
Goto https://console.firebase.google.com -> select your project.
Settings -> Cloud Messaging -> Project credentials -> Sender ID
Hope this help!
scriptkiddie1
Updated on June 18, 2022Comments
-
scriptkiddie1 almost 2 years
I am trying to use push notification for my web site..
I am trying fcm. In the Google documentation (https://firebase.google.com/docs/cloud-messaging/js/client) they told us to use gcm_sender_id in
manifest.json
file, but I don't find it any where in firebase page https://console.firebase.google.com/project/fir-98798789/overviewAlso they have mentioned
Don't confuse the "browser sender ID" with the project-specific sender ID value shown in your Firebase project settings. The browser sender ID for manifest.json is a fixed value, common among all FCM JavaScript clients.