androidfirebasefirebase-remote-config

Firebase Remote Config: Can't read any values, but fetch is successful


I'm trying to have a remote config parameter using the new Remote Config feature of Firebase, and I'm having an issue.

Here's my Remote Config console: remote config console

I'm doing a fetch and update in my Application's onCreate():

final FirebaseRemoteConfig remoteConfig = FirebaseRemoteConfig.getInstance();
remoteConfig.fetch().addOnCompleteListener(new OnCompleteListener<Void>() {
    @Override
    public void onComplete(@NonNull Task<Void> task) {
        if (task.isSuccessful()) {
            remoteConfig.activateFetched();
        }
    }
});

And here's how I'm reading it:

FirebaseRemoteConfig remoteConfig = FirebaseRemoteConfig.getInstance();
String value = remoteConfig.getString("active_subscriptions");

Value is returning null.

If I call remoteConfig.getInfo().getLastFetchStatus(), it returns LAST_FETCH_STATUS_SUCCESS, so it seems the fetch is going through successfully.

Any idea why my value is blank?


Solution

  • Found the problem.

    After adding some logging, I found that the fetch job's onComplete() was never being called. I moved the fetch from my Application's onCreate to a fragment's, and now it works properly!

    (Ian Barber, this might be something to look into or clarify, as the logs indicated that Firebase was initialized without an issue when it was in the Application, and the fetches were silent failures.)