Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get Firebase's project name from Android?

I have an app with Firebase integrated. We switch back and forth between project "Development" and project "Production" in Firebase.

enter image description here

On Android, switching the project is done by replacing the google-services.json file. Is there any way I can get the Firebase's project name (i.e. Temu Production and Temu Development) from inside Android? Something like FirebaseApp.getInstance().getProjectName()?

I'm new to Firebase so I'm open to various approaches on project management and infrastructure.

like image 474
Okihita Avatar asked Mar 13 '17 04:03

Okihita


People also ask

How do I find my Android project ID?

Go to the API Console. From the projects list, select Manage all projects. The names and IDs for all the projects you're a member of are displayed.

Can I rename Firebase project?

There is no way to change the ID of a project. You have to create a new one.

Can you connect more than one Firebase project to your Android app?

However, when you want to access multiple projects from a single application, you'll need a distinct Firebase application object to reference each one individually. It's up to you to initialize these other instances.


1 Answers

The project name is provided by the FirebaseApp class.

Android:

FirebaseApp.getInstance().getOptions().getProjectId() should do the trick.

iOS (Swift):

FirebaseApp.app()?.options.projectID works well.

like image 69
Guven Avatar answered Sep 21 '22 04:09

Guven