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:
- static data which might frequently changed or if changed should be reflected instantly
- feature flag
- force update (min_version) version definition
What makes firebase remote config also powerful are:
- it has no limits
- 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
andGoogleServices-Info.plist
Installation Steps
-
Install
expo-dev-client
npx expo install expo-dev-client
-
Install React Native Firebase
npx expo install @react-native-firebase/app
-
Update
app.config.json
/app.config.ts
/app.config.js
- make sure
ios.bundleIdentifier
andandroid.package
is defined - define the google services file location in
ios.googleServicesFile
andandroid.googleServicesFile
- Add
@react-native-firebase/*
toplugins
for each@react-native-firebase/*
which hasapp.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', }, }, ], ], })
- make sure
-
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