firebase:: remote_config:: RemoteConfig
#include <remote_config.h>
Entry point for the Firebase C++ SDK for Remote Config.
Summary
To use the SDK, callfirebase::remote_config::RemoteConfig::GetInstance() to obtain an instance ofRemoteConfig, then call operations on that instance. The instance contains the complete set of FRC parameter values available to your app. The instance also stores values fetched from the FRC Server until they are made available for use with a call toActivate().
Constructors and Destructors | |
|---|---|
~RemoteConfig() |
Public functions | |
|---|---|
Activate() | Future< bool >Asynchronously activates the most recently fetched configs, so that the fetched key value pairs take effect. |
ActivateLastResult() | Future< bool >Get the (possibly still pending) results of the most recentActivate() call. |
AddOnConfigUpdateListener(std::function< void(ConfigUpdate &&,RemoteConfigError)> config_update_listener) | Starts listening for real-time config updates from the Remote Config backend and automatically fetches updates from the RC backend when they are available. |
EnsureInitialized() | Returns aFuture that containsConfigInfo representing the initialization status of this Firebase Remote Config instance. |
EnsureInitializedLastResult() | Get the (possibly still pending) results of the most recentEnsureInitialized() call. |
Fetch() | Future< void >Fetches config data from the server. |
Fetch(uint64_t cache_expiration_in_seconds) | Future< void >Fetches config data from the server. |
FetchAndActivate() | Future< bool >Asynchronously fetches and then activates the fetched configs. |
FetchAndActivateLastResult() | Future< bool >Get the (possibly still pending) results of the most recentFetchAndActivate() call. |
FetchLastResult() | Future< void >Get the (possibly still pending) results of the most recentFetch() call. |
GetAll() | std::map< std::string,Variant >Returns a Map of Firebase Remote Config key value pairs. |
GetBoolean(const char *key) | boolReturns the value associated with a key, converted to a bool. |
GetBoolean(const char *key,ValueInfo *info) | boolReturns the value associated with a key, converted to a bool. |
GetConfigSettings() | Gets the current settings of theRemoteConfig object. |
GetData(const char *key) | std::vector< unsigned char >Returns the value associated with a key, as a vector of raw byte-data. |
GetData(const char *key,ValueInfo *info) | std::vector< unsigned char >Returns the value associated with a key, as a vector of raw byte-data. |
GetDouble(const char *key) | doubleReturns the value associated with a key, converted to a double. |
GetDouble(const char *key,ValueInfo *info) | doubleReturns the value associated with a key, converted to a double. |
GetInfo() | constConfigInfoReturns information about the last fetch request, in the form of aConfigInfo struct. |
GetKeys() | std::vector< std::string >Gets the set of all keys. |
GetKeysByPrefix(const char *prefix) | std::vector< std::string >Gets the set of keys that start with the given prefix. |
GetLong(const char *key) | int64_tReturns the value associated with a key, converted to a 64-bit integer. |
GetLong(const char *key,ValueInfo *info) | int64_tReturns the value associated with a key, converted to a 64-bit integer. |
GetString(const char *key) | std::stringReturns the value associated with a key, converted to a string. |
GetString(const char *key,ValueInfo *info) | std::stringReturns the value associated with a key, converted to a string. |
SetConfigSettings(ConfigSettings settings) | Future< void >Asynchronously changes the settings for this Remote Config instance. |
SetConfigSettingsLastResult() | Future< void >Get the (possibly still pending) results of the most recentSetConfigSettings() call. |
SetDefaults(constConfigKeyValueVariant *defaults, size_t number_of_defaults) | Future< void >Sets the default values based on a mapping of string toVariant. |
SetDefaults(constConfigKeyValue *defaults, size_t number_of_defaults) | Future< void >Sets the default values based on a string map. |
SetDefaultsLastResult() | Future< void >Get the (possibly still pending) results of the most recentSetDefaults() call. |
app() | App *Gets theApp this remote config object is connected to. |
Public static functions | |
|---|---|
GetInstance(App *app) | Returns theRemoteConfig object for anApp. |
Public functions
Activate
Future<bool>Activate()
Asynchronously activates the most recently fetched configs, so that the fetched key value pairs take effect.
| Details | |
|---|---|
| Returns | AFuture that contains true if fetched configs were activated. The future will contain false if the configs were already activated. |
ActivateLastResult
Future<bool>ActivateLastResult()
Get the (possibly still pending) results of the most recentActivate() call.
| Details | |
|---|---|
| Returns | The future result from the last call toActivate(). |
AddOnConfigUpdateListener
ConfigUpdateListenerRegistrationAddOnConfigUpdateListener(std::function<void(ConfigUpdate&&,RemoteConfigError)>config_update_listener)
Starts listening for real-time config updates from the Remote Config backend and automatically fetches updates from the RC backend when they are available.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | A registration object that allows the listener to remove the associated listener. |
EnsureInitialized
Future<ConfigInfo>EnsureInitialized()
Returns aFuture that containsConfigInfo representing the initialization status of this Firebase Remote Config instance.
Use this method to ensure Set/Get call not being blocked.
EnsureInitializedLastResult
Future<ConfigInfo>EnsureInitializedLastResult()
Get the (possibly still pending) results of the most recentEnsureInitialized() call.
| Details | |
|---|---|
| Returns | The future result from the last call toEnsureInitialized(). |
Fetch
Future<void>Fetch()
Fetches config data from the server.
Note: This does not actually apply the data or make it accessible, it merely retrieves it and caches it. To accept and access the newly retrieved values, you must callActivate().Note that this function is asynchronous, and will normally take an unspecified amount of time before completion.
| Details | |
|---|---|
| Returns | AFuture which can be used to determine when the fetch is complete. |
Fetch
Future<void>Fetch(uint64_tcache_expiration_in_seconds)
Fetches config data from the server.
Note: This does not actually apply the data or make it accessible, it merely retrieves it and caches it. To accept and access the newly retrieved values, you must callActivate(). Note that this function is asynchronous, and will normally take an unspecified amount of time before completion.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | AFuture which can be used to determine when the fetch is complete. |
FetchAndActivate
Future<bool>FetchAndActivate()
Asynchronously fetches and then activates the fetched configs.
If the time elapsed since the last fetch from the Firebase Remote Config backend is more than the default minimum fetch interval, configs are fetched from the backend.
After the fetch is complete, the configs are activated so that the fetched key value pairs take effect.
| Details | |
|---|---|
| Returns | AFuture that contains true if the current call activated the fetched configs; if no configs were fetched from the backend and the local fetched configs have already been activated, the future will contain false. |
FetchAndActivateLastResult
Future<bool>FetchAndActivateLastResult()
Get the (possibly still pending) results of the most recentFetchAndActivate() call.
| Details | |
|---|---|
| Returns | The future result from the last call toFetchAndActivate(). |
FetchLastResult
Future<void>FetchLastResult()
GetAll
std::map<std::string,Variant>GetAll()
Returns a Map of Firebase Remote Config key value pairs.
Evaluates the values of the parameters in the following order: The activated value, if the last successfulActivate() contained the key. The default value, if the key was set withSetDefaults().
GetBoolean
boolGetBoolean(constchar*key)
Returns the value associated with a key, converted to a bool.
Values of "1", "true", "t", "yes", "y" and "on" are interpreted (case insensitive) astrue and "0", "false", "f", "no", "n", "off", and empty strings are interpreted (case insensitive) asfalse.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | Value associated with the specified key converted to a boolean value. |
GetBoolean
boolGetBoolean(constchar*key,ValueInfo*info)
Returns the value associated with a key, converted to a bool.
Values of "1", "true", "t", "yes", "y" and "on" are interpreted (case insensitive) astrue and "0", "false", "f", "no", "n", "off", and empty strings are interpreted (case insensitive) asfalse.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
| ||||
| Returns | Value associated with the specified key converted to a boolean value. |
GetConfigSettings
ConfigSettingsGetConfigSettings()
Gets the current settings of theRemoteConfig object.
| Details | |
|---|---|
| Returns | AConfigSettings struct. |
GetData
std::vector<unsignedchar>GetData(constchar*key)
Returns the value associated with a key, as a vector of raw byte-data.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | Vector of bytes. |
GetData
std::vector<unsignedchar>GetData(constchar*key,ValueInfo*info)
Returns the value associated with a key, as a vector of raw byte-data.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
| ||||
| Returns | Vector of bytes. |
GetDouble
doubleGetDouble(constchar*key)
Returns the value associated with a key, converted to a double.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | Value associated with the specified key converted to a double. |
GetDouble
doubleGetDouble(constchar*key,ValueInfo*info)
Returns the value associated with a key, converted to a double.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
| ||||
| Returns | Value associated with the specified key converted to a double. |
GetInfo
constConfigInfoGetInfo()
Returns information about the last fetch request, in the form of aConfigInfo struct.
| Details | |
|---|---|
| Returns | AConfigInfo struct, containing fields reflecting the state of the most recent fetch request. |
GetKeys
std::vector<std::string>GetKeys()
Gets the set of all keys.
| Details | |
|---|---|
| Returns | Set of all Remote Config parameter keys. |
GetKeysByPrefix
std::vector<std::string>GetKeysByPrefix(constchar*prefix)
Gets the set of keys that start with the given prefix.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | Set of Remote Config parameter keys that start with the specified prefix. Will return an empty set if there are no keys with the given prefix. |
GetLong
int64_tGetLong(constchar*key)
Returns the value associated with a key, converted to a 64-bit integer.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | Value associated with the specified key converted to a 64-bit integer. |
GetLong
int64_tGetLong(constchar*key,ValueInfo*info)
Returns the value associated with a key, converted to a 64-bit integer.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
| ||||
| Returns | Value associated with the specified key converted to a 64-bit integer. |
GetString
std::stringGetString(constchar*key)
Returns the value associated with a key, converted to a string.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | Value as a string associated with the specified key. |
GetString
std::stringGetString(constchar*key,ValueInfo*info)
Returns the value associated with a key, converted to a string.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
| ||||
| Returns | Value as a string associated with the specified key. |
SetConfigSettings
Future<void>SetConfigSettings(ConfigSettingssettings)
Asynchronously changes the settings for this Remote Config instance.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | aFuture which can be used to determine when the operation is complete. |
SetConfigSettingsLastResult
Future<void>SetConfigSettingsLastResult()
Get the (possibly still pending) results of the most recentSetConfigSettings() call.
| Details | |
|---|---|
| Returns | The future result from the last call toSetConfigSettings(). |
SetDefaults
Future<void>SetDefaults(constConfigKeyValueVariant*defaults,size_tnumber_of_defaults)
Sets the default values based on a mapping of string toVariant.
This allows you to specify defaults of type other than string.
The type of eachVariant in the map determines the type of data for which you are providing a default. For example, boolean values can be retrieved with GetBool(), integer values can be retrieved withGetLong(), double values can be retrieved withGetDouble(), string values can be retrieved withGetString(), and binary data can be retrieved withGetData(). AggregateVariant types are not allowed.
See also:firebase::Variant for more information on how to create aVariant of each type.Note: This completely overrides all previous values.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
| ||||
| Returns | aFuture which can be used to determine when the operation is complete. |
SetDefaults
Future<void>SetDefaults(constConfigKeyValue*defaults,size_tnumber_of_defaults)
Sets the default values based on a string map.
Note: This completely overrides all previous values.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
| ||||
| Returns | aFuture which can be used to determine when the operation is complete. |
SetDefaultsLastResult
Future<void>SetDefaultsLastResult()
Get the (possibly still pending) results of the most recentSetDefaults() call.
| Details | |
|---|---|
| Returns | The future result from the last call toSetDefaults(). |
~RemoteConfig
~RemoteConfig()
Public static functions
GetInstance
RemoteConfig*GetInstance(App*app)
Returns theRemoteConfig object for anApp.
Creates theRemoteConfig if required.
To get theRemoteConfig object for the default app, use, GetInstance(GetDefaultFirebaseApp());
If the libraryRemoteConfig fails to initialize, init_result_out will be written with the result status (if a pointer is given).
| Details | |||
|---|---|---|---|
| Parameters |
|
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-01-23 UTC.