Files
react-native-firebase/docs/app/client.md
Ilja Daderko 16e67ddbf8 Move file methods / constants from storage to utils (#2511)
* stash

* move commons into the app

* move utils module into app

* Update index.d.ts

* re-trigger build

* fix eslint issues

* Fix formatting eslint issues

* move utils documentation to app

* Dissalow number values in setUserProperties

* fix test

* add utils export to app module

* clean up utils export

* Move path helpers to utilities module

* I have no idea

* Update RNFBUtilsModule.m

* remove duplicate util files

* fix RNFBUtilsModule merge conflict

* fix android build

* Move path constants from storage to utils, remove old GH Actions

* resolve remaining merge confs

* resolve type definition conflict

* add requiresMainQueueSetup to RNFBUtilsModule
2019-08-28 13:17:48 +03:00

94 lines
2.6 KiB
Markdown

---
title: Client Initialization
description: Initialization Firebase with the client method.
---
# Client Initialization
> The default firebase app instance can not be initialized via JS. After following the iOS & Android installation guides and correctly setting up your google services plist/json files, the default app is automatically initialized and available for use in react-native-firebase.
App initialization in React Native Firebase is, for the most part, the same as the web SDK, with only a few minor differences.
## Supported Modules
Only some modules on the official Firebase native SDK's support multiple apps, they are as follows:
- Authentication
- Database
- Firestore
- Functions
- Instance ID
- Storage
- ML Kit Natural Language
- ML Kit Vision
For further information, view [Firebase Documentation for Multiple Projects](https://firebase.google.com/docs/web/setup#multiple-projects).
## Initialize apps via JavaScript
### Cross Platform Example
```javascript
import { Platform } from 'react-native';
import firebase from '@react-native-firebase/app';
// pluck values from your `GoogleService-Info.plist` you created on the firebase console
const iosConfig = {
clientId: 'x',
appId: 'x',
apiKey: 'x',
databaseURL: 'x',
storageBucket: 'x',
messagingSenderId: 'x',
projectId: 'x',
// enable persistence by adding the below flag
persistence: true,
};
// pluck values from your `google-services.json` file you created on the firebase console
const androidConfig = {
clientId: 'x',
appId: 'x',
apiKey: 'x',
databaseURL: 'x',
storageBucket: 'x',
messagingSenderId: 'x',
projectId: 'x',
// enable persistence by adding the below flag
persistence: true,
};
const kittensApp = firebase
.initializeApp(
// use platform-specific firebase config
Platform.OS === 'ios' ? iosConfig : androidConfig,
// name of this app
'kittens',
)
.then(app => console.log('initialized apps ->', firebase.apps));
```
## Initialize apps via Android/iOS native code
If you're familiar with native code you can create apps natively also (or if you are already initializing additional apps natively on app boot) - these apps automatically become available for use inside RNFirebase.
For example, if you created an app natively called `dogs` then the following would work:
```javascript
import firebase from '@react-native-firebase/app';
const dogsApp = firebase.app('dogs');
```
## Deleting an app instance
Firebase App instances can be deleted via `app.delete()`.
```js
await firebase.app('kittens').delete();
```
> Note that it's not possible to delete the `default` app instance.