React Native Firebase
    Preparing search index...

    The Firebase Remote RemoteConfig service interface.

    This module is available for the default app only.

    Get the Remote RemoteConfig service for the default app:

    const defaultAppRemoteConfig = firebase.remoteConfig();
    

    Hierarchy (View Summary)

    Index

    Constructors

    Methods

    • Moves fetched data to the apps active config. Resolves with a boolean value true if new local values were activated

      // Fetch values
      await firebase.remoteConfig().fetch();
      const activated = await firebase.remoteConfig().activate();

      if (activated) {
      console.log('Fetched values successfully activated.');
      } else {
      console.log('Fetched values were already activated.');
      }

      Returns Promise<boolean>

    • Ensures the last activated config are available to the getters.

      await firebase.remoteConfig().ensureInitialized();
      // get remote config values

      Returns Promise<void>

    • Fetches the remote config data from Firebase, as defined in the dashboard. If duration is defined (seconds), data will be locally cached for this duration.

      // Fetch and cache for 5 minutes
      await firebase.remoteConfig().fetch(300);

      Parameters

      • OptionalexpirationDurationSeconds: number

        Duration in seconds to cache the data for. To skip cache, use a duration of 0.

      Returns Promise<void>

    • Fetches the remote config data from Firebase, as defined in the dashboard. Once fetching is complete this method immediately calls activate and returns a boolean value true if new values were activated

      // Fetch, cache for 5 minutes and activate
      const fetchedRemotely = await firebase.remoteConfig().fetchAndActivate();

      if (fetchedRemotely) {
      console.log('New configs were retrieved from the backend and activated.');
      } else {
      console.log('No new configs were fetched from the backend, and the local configs were already activated');
      }

      Returns Promise<boolean>

    • Returns all available config values.

      const values = firebase.remoteConfig().getAll();

      Object.entries(values).forEach(($) => {
      const [key, entry] = $;
      console.log('Key: ', key);
      console.log('Source: ', entry.getSource());
      console.log('Value: ', entry.asString());
      });

      Returns ConfigValues

    • Gets a config property using the key and converts to a boolean value

      // true or false depending on truthy or falsy nature of value
      const configValue = firebase.remoteConfig().getBoolean('experiment');

      Parameters

      • key: string

        A key used to retrieve a specific value.

      Returns boolean

    • Gets a config property using the key and converts to a number value. It will be 0 if the value is not a number.

      // number value of 'experiment' property
      const configValue = firebase.remoteConfig().getNumber('experiment');

      Parameters

      • key: string

        A key used to retrieve a specific value.

      Returns number

    • Gets a config property using the key and converts to a string value

      // string value of 'experiment' property
      const configValue = firebase.remoteConfig().getString('experiment');

      Parameters

      • key: string

        A key used to retrieve a specific value.

      Returns string

    • Gets a ConfigValue by key.

      const configValue = firebase.remoteConfig().getValue('experiment');
      console.log('Source: ', configValue.getSource());
      console.log('Value: ', configValue.asString());

      Parameters

      • key: string

        A key used to retrieve a specific value.

      Returns ConfigValue

    • Starts listening for real-time config updates from the Remote Config backend and automatically fetches updates from the Remote Config backend when they are available.

      Parameters

      Returns FirebaseRemoteConfigTypes.Unsubscribe

      An Unsubscribe function to remove the listener.

      If a connection to the Remote Config backend is not already open, calling this method will open it. Multiple listeners can be added by calling this method again, but subsequent calls re-use the same connection to the backend.

      The list of updated keys passed to the callback will include all keys not currently active, and the config update process fetches the new config but does not automatically activate it for you. Typically you will activate the config in your callback to use the new values.

    • Start listening for real-time config updates from the Remote Config backend and automatically fetch updates when they’re available. Note that the list of updated keys passed to the callback will include all keys not currently active, and the config update process fetches the new config but does not automatically activate for you. Typically you will want to activate the config in your callback so the new values are in force.

      Parameters

      Returns () => void

      use official firebase-js-sdk onConfigUpdate now that web supports realtime

    • Deletes all activated, fetched and defaults configs and resets all Firebase Remote Config settings.

      Returns Promise<void>

      Android only - iOS returns Promise but does not reset anything

      await firebase.remoteConfig().reset();
      // get remote config values
    • Set the Remote RemoteConfig settings, currently able to set fetchTimeMillis & minimumFetchIntervalMillis

      await firebase.remoteConfig().setConfigSettings({
      minimumFetchIntervalMillis: 30000,
      });

      Parameters

      • configSettings: ConfigSettings

        A ConfigSettingsWrite instance used to set Remote RemoteConfig settings.

      Returns Promise<void>

    • Sets default values for the app to use when accessing values. Any data fetched and activated will override any default values. Any values in the defaults but not on Firebase will be untouched.

      await firebase.remoteConfig().setDefaults({
      experiment_enabled: false,
      });

      Parameters

      • defaults: ConfigDefaults

        A ConfigDefaults instance used to set default values.

      Returns Promise<null>

    • Sets the default values from a resource file. On iOS this is a plist file and on Android this is an XML defaultsMap file.

      // put in either your iOS or Android directory without the file extension included (.plist or .xml)
      await firebase.remoteConfig().setDefaultsFromResource('config_resource');

      // resource values will now be loaded in with your other config values
      const config = firebase.remoteConfig().getAll();

      Parameters

      • resourceName: string

        The plist/xml file name with no extension.

      Returns Promise<null>

    Properties

    The current FirebaseApp instance for this Firebase service.

    defaultConfig: ConfigDefaults

    Provides an object with the type ConfigDefaults for default configuration values

    fetchTimeMillis: number

    The number of milliseconds since the last Remote RemoteConfig fetch was performed.

    lastFetchStatus: LastFetchStatusType

    The status of the latest Remote RemoteConfig fetch action.

    See the LastFetchStatus statics definition.

    settings: ConfigSettings

    Provides an object which provides the properties minimumFetchIntervalMillis & fetchTimeMillis if they have been set using setConfigSettings({ fetchTimeMillis: number, minimumFetchIntervalMillis: number }). A description of the properties can be found above