App Check

App Check: initializeAppCheck with ReactNativeFirebaseAppCheckProvider, getToken/getLimitedUseToken, setTokenAutoRefreshEnabled, onTokenChanged, SDK_VERSION, debug tokens, and the app_check_token_auto_refresh firebase.json flag.

Prerequisites

  • @react-native-firebase/app installed and native config completed per Getting Started (Android google-services.json, iOS GoogleService-Info.plist, Expo config plugin, or React Native CLI setup). From v26, New Architecture is required for packages with a native bridge.
  • Install App Check: npm install --save @react-native-firebase/app-check or yarn add @react-native-firebase/app-check, then rebuild native apps (cd ios && pod install on iOS).
  • Register each Android and Apple app in the Firebase console App Check settings for the attestation provider you will use (see Register Firebase apps).
  • On iOS React Native CLI projects, register the App Check provider factory before FirebaseApp.configure() (see iOS application delegate setup). The Expo config plugin injects that call order for you.
  • Call initializeAppCheck from JavaScript before requesting tokens or calling App Check-protected Firebase services. On iOS, a pending provider (not configured yet) rejects with appCheck/provider-not-ready. On Android, that string is not used; failures surface as appCheck/token-error (often with a factory "not configured" message). Do not write Android catch paths that look only for provider-not-ready.

Example Expo Router screen: https://github.com/invertase/react-native-firebase/blob/main/test-expo/app/app-check.tsx

Installation

This module requires that the @react-native-firebase/app module is already setup and installed. To install the "app" module, view the Getting Started documentation.

bash
# Install & setup the app module
yarn add @react-native-firebase/app

# Install the app-check module
yarn add @react-native-firebase/app-check

# If you're developing your app using iOS, run this command
cd ios/ && pod install

If you're using Expo, add the @react-native-firebase/app-check config plugin to your app.json or app.config.js. The plugin registers the native App Check module before FirebaseApp.configure() (Firebase requires that order). You still call initializeAppCheck from JavaScript. For plugin setup, see the Expo installation section.

json
{
  "expo": {
    "plugins": ["@react-native-firebase/app", "@react-native-firebase/app-check"]
  }
}

Platform support and New Architecture

{/* prettier-ignore */}

PlatformsAndroid, iOS (native Firebase SDK)
New ArchitectureRequired from v26. See Migrating to v26.

Platform notes: Use ReactNativeFirebaseAppCheckProvider (or an inline providerOptions object) for native attestation: DeviceCheck, App Attest, Play Integrity, and the debug provider. firebase-js-sdk ReCaptchaEnterpriseProvider and ReCaptchaV3Provider are web only and have no React Native Firebase equivalent. CustomProvider is supported on other/web fallback platforms; on iOS and Android, initializeAppCheck requires provider options and does not accept a bare CustomProvider.

React Native Firebase exports SDK_VERSION, initializeAppCheck, getToken, getLimitedUseToken, setTokenAutoRefreshEnabled, onTokenChanged, ReactNativeFirebaseAppCheckProvider, CustomProvider, the AppCheckProvider interface, and the React Native provider option types (ReactNativeFirebaseAppCheckProviderOptions, ReactNativeFirebaseAppCheckProviderWebOptions, ReactNativeFirebaseAppCheckProviderAppleOptions, ReactNativeFirebaseAppCheckProviderAndroidOptions, ReactNativeFirebaseAppCheckProviderOptionsMap, ReactNativeFirebaseAppCheckProviderConfig). Each is explained in the section that uses it.

This page does not cover console-only workflows such as App Check metrics dashboards, enforcement toggles, reCAPTCHA score thresholds, or web-only self.FIREBASE_APPCHECK_DEBUG_TOKEN setup. Those live in the Firebase App Check documentation. There is no App Check emulator and no connect*Emulator helper for this package.

What does it do

App Check works alongside other Firebase services to help protect your backend resources from abuse, such as billing fraud or phishing. With App Check, devices running your app use an app or device attestation provider that attests to one or both of the following:

  • Requests originate from your authentic app
  • Requests originate from an authentic, untampered device

This attestation is attached to requests your app makes to Firebase backend resources (and to your own backend servers when you send the token yourself).

This package has built-in support for:

  • DeviceCheck on Apple platforms
  • App Attest on Apple platforms (appAttest, or appAttestWithDeviceCheckFallback)
  • Play Integrity on Android (supports apps published on Google Play, outside Google Play, or both; see the Play Integrity provider guide)
  • Debug providers on both platforms

App Check works with Firebase products such as Realtime Database, Cloud Firestore, Cloud Storage, and Cloud Functions (callable functions). For the full product list and quotas, see the official Firebase App Check documentation.

Usage

Register Firebase apps

Before App Check can issue production tokens, register each Android and Apple app in the Firebase console for the attestation provider you will use. Follow project setup / Step 1 in the matching Firebase guides (console registration only; client initialization on this page uses the React Native API):

For App Attest, also add the App Attest capability to the app target in Xcode and set the App Attest environment to production in the .entitlements file (see the App Attest on Apple platforms guide, step 2). With appAttestWithDeviceCheckFallback, the native provider uses App Attest on iOS 14 and later and DeviceCheck on earlier iOS versions.

iOS application delegate setup

Firebase requires the App Check provider factory to be registered before FirebaseApp.configure(). Until initializeAppCheck configures a real provider, the native facade stays pending and token APIs fail closed with appCheck/provider-not-ready (they do not fall back to the debug provider).

Bridging header (React Native with a Swift application entry)

The App Check pod does not expose a Swift-importable module surface, so do not import RNFBAppCheck in Swift. Edit the bridging header at ios/<YourProject>/<YourProject>-Bridging-Header.h and add:

objc
#import "RNFBAppCheckModule.h"

react-native 0.77 and later (Swift application entry)

Call these two lines at the top of application(_:didFinishLaunchingWithOptions:) in your iOS application entry Swift file, before any other Firebase setup in that method. Import FirebaseCore if the file does not already import it.

swift
RNFBAppCheckModule.sharedInstance()
FirebaseApp.configure()

react-native < 0.77 (Objective-C++ application entry)

Add the App Check import, then call sharedInstance before [FIRApp configure]:

objectivec
#import "RNFBAppCheckModule.h"

[RNFBAppCheckModule sharedInstance];
[FIRApp configure];

Configure a React Native provider

ReactNativeFirebaseAppCheckProvider is the React Native-specific AppCheckProvider implementation used to select native attestation providers. There is no firebase-js-sdk equivalent export.

ReactNativeFirebaseAppCheckProviderOptions is the shared base options shape (debugToken). Platform shapes extend it:

  • ReactNativeFirebaseAppCheckProviderAndroidOptions: provider is debug or playIntegrity
  • ReactNativeFirebaseAppCheckProviderAppleOptions: provider is debug, deviceCheck, appAttest, or appAttestWithDeviceCheckFallback
  • ReactNativeFirebaseAppCheckProviderWebOptions: provider is debug, reCaptchaV3, or reCaptchaEnterprise, plus optional siteKey for web or other-platform options

ReactNativeFirebaseAppCheckProviderOptionsMap is the cross-platform map passed to configure() (android, apple, web). Invalid Android or Apple provider name strings throw synchronously from initializeAppCheck validation (Invalid App Check provider "...").

The optional web block is for other/web only (reCAPTCHA). Native React Native iOS/Android initialization uses android / apple and does not need a reCAPTCHA site key.

js
import { ReactNativeFirebaseAppCheckProvider } from '@react-native-firebase/app-check';

function createRnfbAppCheckProvider() {
  const rnfbProvider = new ReactNativeFirebaseAppCheckProvider();
  rnfbProvider.configure({
    android: {
      provider: __DEV__ ? 'debug' : 'playIntegrity',
    },
    apple: {
      provider: __DEV__ ? 'debug' : 'appAttestWithDeviceCheckFallback',
    },
    // other/web only: omit on native RN; no reCAPTCHA site key required for iOS/Android
    web: {
      provider: 'reCaptchaV3',
      siteKey: 'your-recaptcha-site-key',
    },
  });
  return rnfbProvider;
}

Do not call getToken() on a ReactNativeFirebaseAppCheckProvider instance. It only satisfies the AppCheckProvider interface and always rejects, because native modules fetch the token. Use modular getToken(appCheckInstance) after initializeAppCheck instead (see Get a token).

Initialize App Check

initializeAppCheck(app, options) returns an AppCheck instance synchronously (firebase-js-sdk modular parity). On success it returns that instance immediately and starts native configureProvider in the background (void on the instance Promise; modular does not return a Promise). Invalid options still throw synchronously. A failure during that background provider setup is reported with console.warn (it is not an unhandled rejection you can await). Pass an explicit FirebaseApp from getApp().

AppCheckOptions.provider accepts a ReactNativeFirebaseAppCheckProvider, or a ReactNativeFirebaseAppCheckProviderConfig object with providerOptions (inline convenience config). On native platforms the provider must expose providerOptions. Missing providerOptions is a synchronous throw from the instance initializeAppCheck path (Invalid configuration: no provider or no provider options defined.) before configureProvider runs. That throw propagates through modular initializeAppCheck; it is not a background Promise rejection you can await. Missing platform-specific provider strings (android.provider / apple.provider while on that OS) also throw synchronously.

js
import { getApp } from '@react-native-firebase/app';
import {
  ReactNativeFirebaseAppCheckProvider,
  initializeAppCheck,
} from '@react-native-firebase/app-check';

function prepareAppCheck() {
  const rnfbProvider = new ReactNativeFirebaseAppCheckProvider();
  rnfbProvider.configure({
    android: {
      provider: __DEV__ ? 'debug' : 'playIntegrity',
    },
    apple: {
      provider: __DEV__ ? 'debug' : 'appAttestWithDeviceCheckFallback',
    },
  });

  const appCheck = initializeAppCheck(getApp(), {
    provider: rnfbProvider,
    isTokenAutoRefreshEnabled: true,
  });

  console.log('App Check app name:', appCheck.app.name);
  return appCheck;
}

Inline provider configuration

If you do not need to keep a provider instance around, pass ReactNativeFirebaseAppCheckProviderConfig inline via providerOptions:

js
import { getApp } from '@react-native-firebase/app';
import { initializeAppCheck } from '@react-native-firebase/app-check';

function prepareAppCheckInline() {
  const appCheck = initializeAppCheck(getApp(), {
    provider: {
      providerOptions: {
        android: {
          provider: __DEV__ ? 'debug' : 'playIntegrity',
        },
        apple: {
          provider: __DEV__ ? 'debug' : 'appAttestWithDeviceCheckFallback',
        },
      },
    },
    isTokenAutoRefreshEnabled: true,
  });
  return appCheck;
}

Get a token

getToken(appCheckInstance, forceRefresh?) returns a Promise of AppCheckTokenResult ({ token }). When forceRefresh is omitted or false, the native SDK may return a cached token. When true, it requests a fresh token.

If App Check is still pending (no successful initializeAppCheck provider configure yet):

  • iOS: rejects with appCheck/provider-not-ready.
  • Android: does not use provider-not-ready; rejects through appCheck/token-error, often with a factory message that the provider is not configured for the app.
js
import { getApp } from '@react-native-firebase/app';
import { initializeAppCheck, getToken } from '@react-native-firebase/app-check';

async function verifyAppCheckToken() {
  const appCheck = initializeAppCheck(getApp(), {
    provider: {
      providerOptions: {
        android: { provider: __DEV__ ? 'debug' : 'playIntegrity' },
        apple: { provider: __DEV__ ? 'debug' : 'appAttestWithDeviceCheckFallback' },
      },
    },
    isTokenAutoRefreshEnabled: true,
  });

  const { token } = await getToken(appCheck, true);
  console.log('App Check verification passed, token length:', token.length);
  return token;
}

Limited-use tokens

getLimitedUseToken(appCheckInstance) requests a limited-use App Check token for non-Firebase backend servers that use replay protection. It does not change how getToken refreshes the standard cached token. Pending providers (not configured yet) use the same platform-specific reject codes as getToken: appCheck/provider-not-ready on iOS only; appCheck/token-error (including factory "not configured") on Android.

js
import { getApp } from '@react-native-firebase/app';
import { initializeAppCheck, getLimitedUseToken } from '@react-native-firebase/app-check';

async function fetchLimitedUseToken() {
  const appCheck = initializeAppCheck(getApp(), {
    provider: {
      providerOptions: {
        android: { provider: __DEV__ ? 'debug' : 'playIntegrity' },
        apple: { provider: __DEV__ ? 'debug' : 'appAttestWithDeviceCheckFallback' },
      },
    },
  });

  const { token } = await getLimitedUseToken(appCheck);
  console.log('Limited-use token length:', token.length);
  return token;
}

To send a token to your own backend, put it in a header such as X-Firebase-AppCheck (do not put tokens in URLs or query parameters). Server verification is covered in the Firebase custom backend guide.

Token auto-refresh

setTokenAutoRefreshEnabled(appCheckInstance, isAutoRefreshEnabled) overrides the isTokenAutoRefreshEnabled value from initializeAppCheck.

When isTokenAutoRefreshEnabled is omitted during initialization, React Native Firebase resolves it in this order:

  1. app_check_token_auto_refresh in firebase.json (see firebase.json)
  2. else app_data_collection_default_enabled in firebase.json
  3. else true
js
import { getApp } from '@react-native-firebase/app';
import { initializeAppCheck, setTokenAutoRefreshEnabled } from '@react-native-firebase/app-check';

function toggleTokenAutoRefresh(enabled) {
  const appCheck = initializeAppCheck(getApp(), {
    provider: {
      providerOptions: {
        android: { provider: __DEV__ ? 'debug' : 'playIntegrity' },
        apple: { provider: __DEV__ ? 'debug' : 'appAttestWithDeviceCheckFallback' },
      },
    },
    isTokenAutoRefreshEnabled: false,
  });

  setTokenAutoRefreshEnabled(appCheck, enabled);
}

Listen for token changes

onTokenChanged(appCheckInstance, listener) subscribes to App Check token updates.

On Android, the listener receives { token } updates and returns an unsubscribe function. On iOS, native listening is not implemented: subscribing logs a warning (onTokenChanged is not implemented on IOS, only for Android) and returns a no-op unsubscribe. On iOS, call getToken when you need a current token, or rely on automatic refresh.

Instead of a function, you can pass an observer object with a next method. The onError and onCompletion callbacks are accepted for firebase-js-sdk signature parity but are never called.

js
import { getApp } from '@react-native-firebase/app';
import { initializeAppCheck, onTokenChanged, getToken } from '@react-native-firebase/app-check';

function watchAppCheckToken() {
  // WARNING: onTokenChanged is a no-op on iOS (logs a warning). Prefer getToken
  // when you need a fresh token on Apple platforms.
  const appCheck = initializeAppCheck(getApp(), {
    provider: {
      providerOptions: {
        android: { provider: __DEV__ ? 'debug' : 'playIntegrity' },
        apple: { provider: __DEV__ ? 'debug' : 'appAttestWithDeviceCheckFallback' },
      },
    },
    isTokenAutoRefreshEnabled: true,
  });

  const unsubscribe = onTokenChanged(appCheck, ({ token }) => {
    console.log('App Check token updated, length:', token.length);
  });

  return unsubscribe;
}

async function refreshTokenOnDemand() {
  const appCheck = initializeAppCheck(getApp(), {
    provider: {
      providerOptions: {
        android: { provider: __DEV__ ? 'debug' : 'playIntegrity' },
        apple: { provider: __DEV__ ? 'debug' : 'appAttestWithDeviceCheckFallback' },
      },
    },
  });
  const { token } = await getToken(appCheck, true);
  return token;
}

CustomProvider on other platforms

CustomProvider wraps a getToken() function for custom attestation on other/web platforms. On iOS and Android, pass ReactNativeFirebaseAppCheckProvider or ReactNativeFirebaseAppCheckProviderConfig instead. Constructing CustomProvider without a getToken function throws synchronously (Invalid configuration: no getToken function defined.). The App Check SDK caches tokens, so your getToken should return a newly issued token each time it is called (see the official custom provider guide). The server side of a custom provider is described in Implement a custom App Check provider.

js
import { CustomProvider } from '@react-native-firebase/app-check';

function createOtherPlatformCustomProvider() {
  // WARNING: For other/web platforms only. On iOS and Android, initializeAppCheck
  // requires providerOptions via ReactNativeFirebaseAppCheckProvider or an inline
  // ReactNativeFirebaseAppCheckProviderConfig.
  return new CustomProvider({
    getToken: async () => {
      return {
        token: 'token-from-your-custom-server',
        expireTimeMillis: Date.now() + 60 * 60 * 1000,
      };
    },
  });
}

firebase.json

Token auto-refresh before JS runs

Set app_check_token_auto_refresh in firebase.json when you need a default before the JavaScript bundle runs (for example GDPR opt-in flows). Rebuild the native app after changing it. When isTokenAutoRefreshEnabled is omitted from initializeAppCheck, the JavaScript layer resolves the value in the order listed under Token auto-refresh. The key is also listed in the firebase.json reference.

json
{
  "react-native": {
    "app_check_token_auto_refresh": false
  }
}

After the user consents, call setTokenAutoRefreshEnabled(appCheck, true) (and ensure initializeAppCheck has configured a provider).

Debug provider and tokens

React Native Firebase selects the debug provider through providerOptions (android.provider: 'debug' / apple.provider: 'debug'), optionally with a debugToken string you already registered in the Firebase console. That is the supported JS path for simulators, emulators, and CI. There is no App Check emulator and no connect*Emulator API.

Do not ship production builds with the debug provider enabled. Keep registered debug tokens private; revoke compromised tokens in the Firebase console (Manage debug tokens).

Pass a console-registered debug token from JavaScript

js
import { getApp } from '@react-native-firebase/app';
import { initializeAppCheck } from '@react-native-firebase/app-check';

function prepareDebugAppCheck(debugToken) {
  return initializeAppCheck(getApp(), {
    provider: {
      providerOptions: {
        android: {
          provider: 'debug',
          debugToken,
        },
        apple: {
          provider: 'debug',
          debugToken,
        },
      },
    },
    isTokenAutoRefreshEnabled: true,
  });
}

Android: read a temporary secret from device logs

  1. Start a debug build that uses provider: 'debug' (without setting debugToken).
  2. Run the following and copy the logged secret:
bash
adb logcat | grep DebugAppCheckProvider
  1. In Firebase console Security > App Check > Apps, open Manage debug tokens for the Android app and register that secret.

iOS: read a temporary secret from the Xcode console

  1. Start a debug build that uses provider: 'debug' (without setting debugToken).
  2. Open the Xcode console and copy the logged App Check debug token.
  3. In Firebase console Security > App Check > Apps, open Manage debug tokens for the Apple app and register that token.

See the official Android and Apple platforms debug provider guides for the exact log output. On Apple platforms, to get a new debug token after deleting one in the console, uninstall and reinstall the app so a fresh token is generated.

CI: pass a registered token from your secret store

Create a debug token in the Firebase console, store it in your CI secret store, and read it into your JavaScript at build or run time (for example from an environment variable you inject into your app config). Pass it as debugToken as shown in Pass a console-registered debug token from JavaScript.

Troubleshooting

appCheck/provider-not-ready (iOS only)

On iOS, if getToken / getLimitedUseToken rejects with appCheck/provider-not-ready, App Check has not been configured yet for that app (pending native facade / nil delegate provider). Call initializeAppCheck with a valid native provider before requesting tokens or calling App Check-protected Firebase services. Also confirm the iOS application delegate registers RNFBAppCheckModule.sharedInstance() before FirebaseApp.configure() (or that the Expo config plugin did).

Until initializeAppCheck configures a provider, the iOS native module does not install the debug provider and does not send token requests to Firebase. If you see unexpected exchangeDebugToken requests, look for a code path that requests a token before initializeAppCheck completes and move it after.

Android does not emit provider-not-ready. When App Check is not configured on Android, token APIs reject as appCheck/token-error (for example when the provider factory reports that ReactNativeFirebaseAppCheckProvider is not configured for the app). Catch token-error / inspect the message on Android; do not rely on provider-not-ready there.

Other token error codes

getToken and getLimitedUseToken reject with appCheck/token-error when the native Firebase SDK fails to produce a token (the message is the native error message). On iOS they reject with appCheck/token-null when the native SDK returns neither a token nor an error.

Missing providerOptions (synchronous throw)

If you pass a provider without providerOptions on native platforms, modular initializeAppCheck throws synchronously with Invalid configuration: no provider or no provider options defined. before native configureProvider. Catch that with a normal try/catch around the call; there is no Promise rejection to await for this case.

Package version

SDK_VERSION is the React Native Firebase App Check package version string exported from @react-native-firebase/app-check. The firebase-js-sdk does not export SDK_VERSION from firebase/app-check.

js
import { SDK_VERSION } from '@react-native-firebase/app-check';

console.log('App Check package version:', SDK_VERSION);