Dynamic Firebase SenderID for Android Push Notification

1.8k Views Asked by At

I have an react-native app with Firebase that doesn't use google-services.json on build and then call FirebaseApp.initializeApp() manually passing the correct values in my google-services.json after the app is running. But in this case I can't send push notifications for Android users because of the SenderID that is not on the google-services.json there is some Firebase function that I can know my SenderID ? Or is another way to send push notifications on Android in react-native without the SenderID ?

2

There are 2 best solutions below

0
Kashan Haider On

No there is no otherways, Using google-services.json is compulsory as it contains all your API credentials.

SenderID is required because firebase notification uses firebase cloud messaging and that will not work without proper google-services.json file with all API credentials including the senderID.

Yes you can get your senderId from firebase project settings , You can also read here. https://dev.tapjoy.com/en/faq/how-to-find-sender-id-and-api-key-for-gcm .

And if you are talking about device tokens, You have to generate them , they are generated for a limited time period and they are unique tokens for each device . You can use any library for generating these tokens, i recommend using this library https://www.npmjs.com/package/react-native-push-notification

0
LanDenLabs On

The push sender id can be found at the top of the google-services.json Look for project_number

google-services.json
{
   "project_info": {
   "project_number": "123456789",     <-- Sender ID -->
   "firebase_url": "https://blah-blau-app.firebaseio.com",
   "project_id": "blah-blau-app",
   "storage_bucket": "blah-blau-app.appspot.com"
},. . .