2
votes

This is the code that I have:

  final FirebaseRemoteConfig config = FirebaseRemoteConfig.getInstance();
    FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder()
            .setDeveloperModeEnabled(BuildConfig.DEBUG)
            .build();
    config.setConfigSettings(configSettings);
    config.fetch(0).addOnCompleteListener(new OnCompleteListener<Void>() {
        @Override
        public void onComplete(@NonNull Task<Void> task) {
            if (task.isSuccessful()) {
                // After config data is successfully fetched, it must be activated before newly fetched
                // values are returned.
                config.activateFetched();
                    final String playStoreVersionCode = FirebaseRemoteConfig.getInstance().getString(
                            "android_latest_version_code");
            } else {
                Utils.appendLog("playStoreVersionCode Error fetching latest params ", "E", Constants.TIMELINE);
            }
        }
    });

Now I want to increment my parameter, and I saw that from March there is a REST API in order to update parameters:

https://firebase.google.com/docs/remote-config/api-overview https://firebase.google.com/docs/remote-config/use-config-rest

But I don't really understand the tutorial. Why do I need to use curl? is this really necessary like in the use-config-rest link?

curl --compressed -D headers -H "Authorization: Bearer token" -X GET https://firebaseremoteconfig.googleapis.com/v1/projects/my-project-id/remoteConfig -o filename

And the quickstart just shows an example on how to fetch the data, not change it: https://github.com/firebase/quickstart-android/blob/master/config/app/src/main/java/com/google/samples/quickstart/config/MainActivity.java

1

1 Answers

5
votes

Remote Config parameters aren't meant to be changed from client code. They're only meant to be read on the client. If you want to change thing programmatically, you're supposed to do that from a server your control.

If you want a read/write some persisted value in your app, don't use Remote Config. Use Realtime Database or Firestore instead.

The reason for showing curl commands in the documentation is to illustrate how to make the HTTP request using a command that many people are familiar with. You can make the HTTP request any way you want, as long as you follow the specification.