mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-04-10 22:48:09 +08:00
* 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
56 lines
1.7 KiB
Markdown
56 lines
1.7 KiB
Markdown
---
|
|
title: Quick Start
|
|
description: Getting started with the Utils package in React Native Firebase
|
|
---
|
|
|
|
# Utils Quick Start
|
|
|
|
> This module automatically comes with the `@react-native-firebase/app` package, there are no additional steps required to install it.
|
|
|
|
## Module usage
|
|
|
|
Import the Utils package into your project:
|
|
|
|
```js
|
|
import { utils } from '@react-native-firebase/app';
|
|
|
|
// utils().X
|
|
|
|
import firebase from '@react-native-firebase/app';
|
|
|
|
// firebase.utils().X
|
|
```
|
|
|
|
## Utilities
|
|
|
|
### Detect whether your app is running within Firebase Test Lab
|
|
|
|
Firebase [TestLab](https://firebase.google.com/docs/test-lab/?utm_source=invertase&utm_medium=react-native-firebase&utm_campaign=utils)
|
|
is a cloud-based app-testing infrastructure. With one operation, you can test your Android or iOS app across
|
|
a wide variety of devices and device configurations, and see the results—including logs, videos,
|
|
and screenshots—in the Firebase console.
|
|
|
|
It is useful to change the apps configuration if it is being run in Test Lab, for example disabling Analytics
|
|
data collection. Such functionality can be carried out by taking advantage of the `isRunningInTestLab` property:
|
|
|
|
```js
|
|
import { utils } from '@react-native-firebase/app';
|
|
import analytics from '@react-native-firebase/analytics';
|
|
|
|
async function bootstrap() {
|
|
if (utils().isRunningInTestLab) {
|
|
await analytics().setAnalyticsCollectionEnabled(false);
|
|
}
|
|
}
|
|
```
|
|
|
|
### Access device file paths
|
|
|
|
Some modules require access to your local device filesystem (such as Storage & ML Kit Vision). The utils module provides paths to common device directory locations.
|
|
|
|
```js
|
|
import firebase from '@react-native-firebase/app';
|
|
// Access the device pictures directory
|
|
const picturesDir = firebase.utils.FilePath.PICTURES_DIRECTORY;
|
|
```
|