Firebase google-services.json file - android

I have a question regarding the Firebase google-services.json file. Every time I add o change something, for example, if I add a new SHA1 fingerprint, do I need to download the file again and put it on the app folder of my Android project? or just the file created the first time is enough?
I am asking because I am having issues with the Phone authentication and I need to know if the problem lies on this matter.

Yes, every time you add a fingerprint (or new package name) you will need to pull down the google-services.json.

Related

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.
I suggest having a read on controlling your Firebase registration/instance it also explains not only how to manually initialise your own firebase with custom options/name but also how firebase initialises itself automatically using the Google plugin and json file which will help you better understand what solution may be best for you.
Essentially you need to manually initialise your Firebase service in your Android apps Application class and provide a FirebaseOptions.Builder class to the Firebase.initializeApp, which allows you to call setGcmSenderId among other things like api key etc.
This official link shows how to configure mutliple projects in your application which may be an option too.
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.
the sender id and project details are set using configuration file "google-services.json",it reads this file from app folder of your android project.
to get google-services.json for your firebase project in firebase console, open project settings and select your app and download the file and place it inside app folder of your android project.

How to store user data in .env file in React Native app

I want the user to store his key and API in .env file. These data will obviously vary from user to user. So every user will have his own set of .env file. How can I achieve this?
Maintainer of react-natiev-dotenv here!
I recently added a feature to use .env.local from dotenv flow. Add .env.local to your .gitignore and ask each user to add their custom API keys in there. I hope this answers your question!

dynamic google-service.json after apk is generated

I have an app that sync data with my API.
I want this app have a dynamic "google-service.json", I want to pass the google-service.json after the app.APK is ready and the app is installed on the device through my API.
Is possible ?
I did a generic "google-service.json" that change the values when I send data from my API to the installed app on the device but the Firebase connection is not working.
Any ideas ?
What you're asking isn't possible. The values from google-services.json are read at build time and added to your APK. There's no way to go back and changes those values later.
If you want to initialize Firebase based on values that can only be known when the app is launched, then you should NOT apply the google-sevices plugin in build.gradle, and instead call FirebaseApp.initializeApp() manually and pass the correct values that you see in google-services.json.
Read:
https://firebase.googleblog.com/2017/03/take-control-of-your-firebase-init-on.html
https://developers.google.com/android/guides/google-services-plugin

I have changed the package name of my app but on Firebase, it is still the previous one. Please see details

I decided to change my app's package name and changed it using this tactic: https://stackoverflow.com/a/29092698/6144372 and then manually changed the package name defined in google-services.json file under this tag: "package_name": "com.xxx.xxx", but when I saw the package name in the Settings section of Firebase Console, it still shows the old one there.
So, I wanted to know that will it cause some bad effect on my app's performance in future or will it not do any harm? Please let me know
And if there is some way of changing the package name in Firebase Console settings too, let me know that too.
You should consider creating a new Firebase project. Just delete the old project and create a new one, with your new package name. I am not sure about the performance issues of just changing the old google-services.json file, but creating a new project is certainly more secure to prevent any future issues.
UPDATE: Thanks to TommieC.'s comment, a better way would be to add a new app to the project and just delete the old app. The new app will have your updated package name. Then download the google-services.json and replace it with the old file.
This method would be safer, in case your firebase project already has different integrations and deleting it is not really an option.
The problem arises when your firebase package name and application ID doesnot match. There is no any rename features in firebase project. You should create the new firebase project that matches the application Id and delete the old project. Then just import respective firebase project json to your code project. That should do the trick

My existing Keystore does not exists

I was updating my code for next version. After i clicked "export signed Application package", i got this error stating that my keystore does not exists. Actually i didn't delete it for sure. Now i am unable to update the app since the existing keystore vanished. Just to check whether i have deleted the file, i tried all recovery software. But unable to find. Tried all similar questions and there was no suitable result. Now please help me to recover the the old keystore.
(sorry for bad English)
First Check out ,Where is your key Storeexits ? at the default location or you have stored at some where else.
Default Path
Other Location
If you are storing your Key Store at other location then check out that rebuild time so you will get idea.
And if there is a okay with everything the issue is about password.
So,It will be good if you Create New Key Store and use it
You cannot create upgrade application if you loss app's keystore.
You have to rename your package, create new keystore and publish as a new application.
There are some rules about keystore:
When create keystore, you have to choose expired date is greater
than 20 years.
Create with password to sure that you can remember
it.
Keep the keystore file you generate with Keytool in a safe,
secure place (Best place is on Google Drive but please not
same account that you published your app, Dropbox, Box, ... ) and never loss
it. If you loss it, you have to do same above things.
Hope this help to remember.

Categories

Resources