I use Firebase Remote Config to retrieve data the first time I open the application for the first time. But the problem is that I can’t get the data the first time I launch the application. onComplete()calls triggers but does not return a value. If I close the application and run it, it will return the value from Remote Config.
Tried cause fetch () a onCreate(), onStart(), onResume()gave it a second delay postDelay(), however, the initial sample is always empty. I know that Remote Config has a method setDefaults()for storing default values before it is retrieved, but the default setting inside the application is not what I want.
How does Remote Config work, or am I doing something wrong? The only workaround I found was to add fetch()inside onResume()and call the Resume () function inside again onCreate(). This causes onResume () to be called twice. The first time on the Android system and the second time on the code.
Is there any other way to force Remote Config data retrieval on first run?
UPDATE
Inside onComplete()I must first call firebaseRemoteConfig.activateFetched();before getting new values from it.
source
share