Refresh the remote config in Firebase is not updateing unless restart (kill) the app

Viewed 1601

I started implementing the Remote config and I am doing the fetch after I update the info on the server, but when I restart (kill) the app the remote info is updated and visible to the app. The update happens immediately after (kill/restart) the app. What should I do in the app to get the update without kill the app? The user won't kill the app, but it needs the new info from remote config. I have 2 methods that I use: first is for On Create:

FirebaseRemoteConfig.getInstance().fetchAndActivate().addOnCompleteListener(this, new OnCompleteListener<Boolean>() {
                        @Override
                        public void onComplete(@NonNull Task<Boolean> task) {
                            if (task.isSuccessful()) {
                                boolean updated = task.getResult();
                                if (updated) {
                                    //do some updates on local device with the info.
                                }
                                Logs.logMsg("Fetch and activate succeeded. Config params updated: " + updated);
                            } else {
                                Logs.logMsg("task is NOT Successful. Fetch failed!");
                                    //try later 
                            }
}
                    });

and second is for refresh after an update is push to server (Firebase Remote Config):

FirebaseRemoteConfig.getInstance().fetch(cacheExpirationSeconds).addOnCompleteListener(this, new OnCompleteListener<Void>() {
                        @Override
                        public void onComplete(@NonNull Task<Void> task) {
                            if (task.isSuccessful()) {
                                Logs.logMsg("Fetch and activate succeeded. ");
//do some updates on local device with the info.
                            } else {
                                Logs.logMsg("task is NOT Successful. Fetch failed!");
                                //try again later.
                            }
                        }
                    });
2 Answers

You would have to use fetchAndActivate again. The newly fetched values need to be activated in order to see them. A fetch without activate will not cause any changes to be seen.

Related