The Firebase Remote Config Java quickstart app demonstrates fetching and updating the Firebase Remote Config template.
This is a simple example of using the Firebase Remote Config REST API to update the Remote Config template being used by clients apps.
- Add Firebase to your Android Project.
- Create a service account as described in Adding Firebase to your Server and download the JSON file.
- Copy the private key JSON file to this folder and rename it to
service-account.json.
- Change the
PROJECT_IDvariable inMessenger.javato your project ID.
- From the
configdirectory run./gradlew build run -Pfetchto fetch the template. - Store the returned template in a file.
- Update the template.
- From the
configdirectory run./gradlew build run -Ppushto update the template. - Confirm in the console that the template has been updated.
This section provides some additional information about how the Remote Config REST API should be used when fetching and updating templates.
Every fetch of the Remote Config template contains an Etag. This Etag is a unique identifier of the current template on the server. When submitting updates to the template you must submit your last fetched Etag to ensure that your updates are consistent.
In the event that you want to completely overwrite the server's template use an Etag of "*". Use this with caution since this operation cannot be undone.