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.');
}
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);
OptionalexpirationDurationSeconds: numberDuration in seconds to cache the data for. To skip cache, use a duration of 0.
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 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());
});
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');
A key used to retrieve a specific value.
Gets a ConfigValue by key.
const configValue = firebase.remoteConfig().getValue('experiment');
console.log('Source: ', configValue.getSource());
console.log('Value: ', configValue.asString());
A key used to retrieve a specific value.
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.
The RemoteConfig instance.
The ConfigUpdateObserver to be notified of config updates.
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.
called with either array of updated keys or error arg when config changes
Set the Remote RemoteConfig settings, currently able to set fetchTimeMillis & minimumFetchIntervalMillis
await firebase.remoteConfig().setConfigSettings({
minimumFetchIntervalMillis: 30000,
});
A ConfigSettingsWrite instance used to set Remote RemoteConfig settings.
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,
});
A ConfigDefaults instance used to set default values.
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();
The plist/xml file name with no extension.
The current FirebaseApp instance for this Firebase service.
Provides an object with the type ConfigDefaults for default configuration values
The number of milliseconds since the last Remote RemoteConfig fetch was performed.
The status of the latest Remote RemoteConfig fetch action.
See the LastFetchStatus statics definition.
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
The Firebase Remote RemoteConfig service interface.
Example
Get the Remote RemoteConfig service for the default app: