2.6 KiB
title, description, icon, next, previous
| title | description | icon | next | previous |
|---|---|---|---|---|
| Core/App | Functionality & examples of using the Core/App dependency with React Native Firebase. | //static.invertase.io/assets/social/firebase-logo.png | /app/utils | /storage/usage |
The App module is available by default once you have installed the React Native Firebase library by following the Getting Started documentation. The App module currently provides the following functionality:
- Creating Secondary Firebase App Instances.
- Exposing Utilities to aid development.
Secondary Apps
Unlike the Firebase Web SDK, there is no need to manually call the initalizeApp
method with your project credentials. The native Android & iOS SDKs automatically connect to your Firebase project using
the credentials provided during the Getting Started installation steps. The app module does however provide support
for manually initializing secondary Firebase app instances.
Currently, the native Firebase SDKs only provide functionality for creating secondary apps on the the following services:
- Authentication.
- Realtime Database.
- Cloud Firestore.
- Cloud Functions
- Cloud Storage.
- Instance ID.
- ML Kit Natural Language.
- ML Kit Vision.
- Remote Config.
Initializing secondary apps
The module exposes an initalizeApp method which accepts arguments containing the credentials and options for your secondary
apps:
import firebase from '@react-native-firebase/app';
// Your secondary Firebase project credentials...
const credentials = {
clientId: '',
appId: '',
apiKey: '',
databaseURL: '',
storageBucket: '',
messagingSenderId: '',
projectId: '',
};
const config = {
name: 'SECONDARY_APP',
};
await firebase.initalizeApp(credentials, config);
Once created, you can confirm the app instance has been created by accessing the apps property on the module:
console.log(firebase.apps);
Switching app instance
You can switch app instances at any time whilst developing by calling the app method:
import firebase from '@react-native-firebase/app';
// Example using auth
firebase.app('SECONDARY_APP').auth().currentUser;
The firebase instance is also exported on modules for added convenience, for example:
import auth, { firebase } from '@react-native-firebase/auth';
Deleting instances
You can delete any secondary instances by calling the delete method on the instance:
await firebase.app('SECONDARY_APP').delete();