Use Firebase Remote Config with C++

You can use Firebase Remote Config to define parameters in your app and update their values in the cloud, allowing you to modify the appearance and behavior of your app without distributing an app update.

The Remote Config library is used to store in-app default parameter values, fetch updated parameter values from the service, and control when fetched values are made available to your app. To learn more, see Remote Config API Overview.

Add Remote Config to your app

Android

  1. Add Firebase to your C++ Project.
  2. Link in the following libraries, and include the dependency to your app/build.gradle file (after replacing <sdk_version> with your Android SDK version):
    libapp.a
    libremote_config.a
    compile 'com.google.firebase:firebase-config:10.2.0'
  3. Create a Firebase App, passing in the JNI environment and Activity:
    app = ::firebase::App::Create(::firebase::AppOptions(), jni_env, activity);
  4. Initialize the Remote Config library, as shown:
    ::firebase::remote_config::Initialize(app);

iOS

  1. Add Firebase to your C++ Project.
  2. Add the following dependencies to your Podfile, and include the needed frameworks:
    pod 'Firebase/RemoteConfig'
    firebase.framework
    firebase_remote_config.framework
  3. Create a Firebase App:
    app = ::firebase::App::Create(::firebase::AppOptions());
  4. Initialize the Remote Config library, as shown:
    ::firebase::remote_config::Initialize(app);

Set in-app default parameter values

You can set in-app default parameter values in the Remote Config object, so that your app behaves as intended before it connects to the Remote Config service, and so that default values are available if none are set in the service.

  1. Define a set of parameter names, and default parameter values using a std::map object or a
    std::map object.
  2. Add these values to the Remote Config object using SetDefaults().

Get parameter values to use in your app

Now you can get parameter values from the Remote Config object. If you set values in the Remote Config service, fetched them, and then activated them, those values are available to your app. Otherwise, you get the in-app parameter values configured using SetDefaults().

To get these values, call the method listed below that maps to the data type expected by your app, providing the parameter key as an argument:

Connect your app in the Firebase console

In the Firebase console, add your app to your Firebase project.

Set parameter values in the service (as needed)

  1. In the Firebase console, open your project.
  2. Select Remote Config from the menu to view the Remote Config dashboard.
  3. Define parameters with the same names as the parameters that you defined in your app. For each parameter, you can set a default value (which will eventually override the in-app default value) and conditional values. To learn more, see Remote Config parameters and conditions.

Fetch and activate values from the service (as needed)

  1. To fetch parameter values from the Remote Config service, call the Fetch() method. Any values that you set on the Remote Config Server are fetched and cached in the Remote Config object.
  2. To make fetched parameter values available to your app, call the ActivateFetched() method.

Because these updated parameter values affect the behavior and appearance of your app, you should activate the fetched values at a time that ensures a smooth experience for your user, such as the next time that the user opens your app.

Send feedback about...

Need help? Visit our support page.