Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase messaging - how to set Sender Id when requesting a token in Android?

How can I set the sender id when requesting a registration token for Firebase messaging in Android?

I need this, because I have to have different FB projects for the apps and the server that is sending the notifications. It's described here, but I think the doc is missing something. Searching StackOverflow results in answers that are not up-to-date, also. Can't find the way to do it with the latest version of the API.

like image 667
Mit_ Avatar asked Nov 15 '25 18:11

Mit_


1 Answers

I wanted to keep using the google-services.json, so I didn't want to do the manual init. Then when I read how the Google Services Gradle Plugin works, I was going to make the manual init by using the values from the file - more info here: https://developers.google.com/android/guides/google-services-plugin#processing_the_json_file

In the end, I ended up not changing anything in the code and just changing project_info/project_number in the google-services.json. It's used for gcm_defaultSenderId. Everything looks good, now. Hope it's not used for anything, else. We are using FCM, only, so I think it will be ok. I don't like this, but it will do.

like image 74
Mit_ Avatar answered Nov 17 '25 08:11

Mit_



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!