Files
react-native-firebase/docs/utils/quick-start.md
2019-08-21 10:42:47 +01:00

1.6 KiB

title, description
title description
Quick Start Getting started with the Utils package in React Native Firebase

Utils Quick Start

The utils module comes installed with the app module.

Module usage

Import the Utils package into your project:

import { utils } from '@react-native-firebase/app';

Detect whether the app is running within TestL Lab

Firebase TestLab 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:

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 access to the device directory locations, working cross platform on Android & iOS.

import { utils } from '@react-native-firebase/app';

// Access the device pictures directory
const picturesDir = utils.FilePath.PICTURES_DIRECTORY;