2

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.
                            }
                        }
                    });
George
  • 21
  • 1
  • 3

2 Answers2

0

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.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
0

Surprisingly to me too, Remote Config doesn't seem to be actually real time

So, in order for your users to get real time update, you'd have to send silent push notifications and upon receiving those pushes, you request updates

Steps from other answer on StackOverflow

Official docs

https://firebase.google.com/docs/remote-config/propagate-updates-realtime#android_1

How people use it similarly

https://medium.com/iguanafix-engineering/real-time-remote-config-on-ios-f6d3ca35e8dc

ericn
  • 12,476
  • 16
  • 84
  • 127