Best practices
This section provides some additional information about how the quickstart
example sets in-app default parameter values and fetches values from the Remote
Config service
In-app default parameter values
In-app default values are set using an XML file in this example, but you can
also set in-app default values inline using other setDefault
methods of the
FirebaseRemoteConfig
class.
Then, you can override only those values that you need to change from the
Firebase console. This lets you use Remote Config for any default value that you
might want to override in the future, without the need to set all of those
values in the Firebase console.
Fetch values from the Remote Config service
When an app calls fetch
, locally stored parameter values are used unless the
minimum fetch interval is reached. The minimal fetch interval is determined by:
- The parameter passed to
fetch(long minFetchInterval)
.
- The minimum fetch interval set in Remote Config settings.
- The default minimum fetch interval, 12 hours.
Fetched values are immediately activated when retrieved using fetchAndActivate
.
fetchAndActivate
returns true if the final set of key/value pairs now available
to the application is different to the set before calling fetchAndActivate
, false
is returned otherwise. In the quickstart sample app, you call fetchAndActivate
from the UI by tapping Fetch Remote Config.
To control when fetched values are activated and available to your app use fetch
, the
values are locally stored, but not immediately activated. To activate
fetched values so that they take effect, call the activate
method.
You can also create a Remote Config Setting to enable developer mode, but you
must remove this setting before distributing your app. Fetching Remote Config
data from the service is normally limited to a few requests per hour. By
enabling developer mode, you can make many more requests per hour, so you can
test your app with different Remote Config parameter values during development.