Reputation: 6133
I am quite new to firebase and using it for our iOS, Android chat app.
Previously, we only have 1 configuration (1 database). Now we need to have UAT and Prod env. As a result, I have created new DB in firebase but I don't know how to change database name in our mobile app.
Where/how can I write "alive-ios-10dfe" database name in our mobile app?
Upvotes: 1
Views: 252
Reputation: 598785
From the Firebase documentation on connecting your app to multiple database instances:
Swift:
// Get the default database instance for an app var ref: DatabaseReference! ref = Database.database().reference() // Get a secondary database instance by URL var ref: DatabaseReference! ref = Database.database("https://testapp-1234.firebaseio.com").reference()
Android:
// Get the default database instance for an app private DatabaseReference mDatabase; // ... mDatabase = FirebaseDatabase.getInstance().getReference(); // Get a secondary database instance by URL private DatabaseReference mDatabase; // ... mDatabase = FirebaseDatabase.getInstance("https://testapp-1234.firebaseio.com").getReference();
Note that it is more common to use separate projects for different environments. By having each environment on a separate project, they also get their own set of users, their own access tokens, and are separated in many more ways.
Upvotes: 1