docs: update usage of secondary app (#3430)

I struggled a lot with simply switching the database URL within the [DEFAULT] app instance during run time.
I documented my solution in this ticket: https://github.com/invertase/react-native-firebase/issues/3049

This PR shall reflect my findings with switching app instances.
This commit is contained in:
Lisa Oppermann
2020-05-05 23:44:33 +02:00
committed by GitHub
parent b684c92735
commit 6d54d8c743

View File

@@ -65,19 +65,26 @@ console.log(firebase.apps);
## Switching app instance
You can switch app instances at any time whilst developing by calling the `app` method:
You can switch app instances at any time whilst developing by calling the `app` method with the name of the secondary app:
```js
import firebase from '@react-native-firebase/app';
import '@react-native-firebase/auth';
// Example using auth
firebase.app('SECONDARY_APP').auth().currentUser;
```
The `firebase` instance is also exported on modules for added convenience, for example:
Or pass the secondary app instance you created above directly to the desired module, for example:
```js
import auth, { firebase } from '@react-native-firebase/auth';
import firebase from '@react-native-firebase/app';
import auth from '@react-native-firebase/auth';
// create secondary app as described above
const secondaryApp = await firebase.initalizeApp(credentials, config);
// Example using auth with passing the secondary app instance
auth(secondaryApp).currentUser;
```
## Deleting instances