Base
MobileReact nativeExpo

Firebase Remote Config Setup

Remote Config is a versatile way to control the app without rebuilding the app for updates or using OTA Updates (EAS Updates).

It can be used for:

  1. static data which might frequently changed or if changed should be reflected instantly
  2. feature flag
  3. force update (min_version) version definition

What makes firebase remote config also powerful are:

  1. it has no limits
  2. we can configure conditional for each parameter / key

Setup - React Native Firebase

This guide is used if we require access to firebase services not supported by Firebase JS SDK (Crashlytics, Remote Config - as remote config JS SDK needs IndexedDB access).

React Native Firebase requires custom native code and cannot be used with Expo Go.

Pre-Requisites

  • Create Firebase Project ([optional suggestion] one for dev/staging and one for production)
  • Add Android and iOS app to each project, download the google-services.json and GoogleServices-Info.plist

Installation Steps

  1. Install expo-dev-client

    npx expo install expo-dev-client
  2. Install React Native Firebase

    npx expo install @react-native-firebase/app
  3. Update app.config.json / app.config.ts / app.config.js

    • make sure ios.bundleIdentifier and android.package is defined
    • define the google services file location in ios.googleServicesFile and android.googleServicesFile
    • Add @react-native-firebase/* to plugins for each @react-native-firebase/* which has app.config.js
    import type { ConfigContext, ExpoConfig } from '@expo/config'
     
    import { ClientEnv, Env } from './env'
     
    export default ({ config }: ConfigContext): ExpoConfig => ({
      ...,
      ios: {
        ...,
        bundleIdentifier: Env.BUNDLE_ID,
        googleServicesFile:
          Env.APP_ENV === 'production'
            ? process.env.GOOGLE_SERVICE_INFO_PLIST_FILE
            : Env.GOOGLE_SERVICE_INFO_PLIST_FILE,
      },
      android: {
        ...,
        package: Env.PACKAGE,
        googleServicesFile:
          Env.APP_ENV === 'production'
            ? process.env.GOOGLE_SERVICES_JSON_FILE
            : Env.GOOGLE_SERVICES_JSON_FILE,
      },
      plugins: [
        '@react-native-firebase/app',
        ...,
        [
          'expo-build-properties',
          {
            ...,
            ios: {
              ...,
              useFrameworks: 'static',
            },
          },
        ],
      ],
    })
  4. Install RN Firebase remote config

    RN Firebase Remote Config requires analytics module to be installed first

    npx expo install @react-native-firebase/analytics
    npx expo install @react-native-firebase/remote-config

    References: https://rnfirebase.io/remote-config/usage

References:

On this page