I'm using Firebase Remote Config to fetch data when app first open for the first time. But problem is I cannot fetch data on first start of the app. onComplete()
method triggers but returns no value. If I close app and run again it returns value from Remote Config.
Tried to call fetch() in onCreate()
, onStart()
, onResume()
, gave it a second delay with postDelay()
still the same, initial fetch is always empty. I know, Remote Config has setDefaults()
method to store defaults before it is getting fetched, but setting defaults inside app is not what I want.
It is the way how Remote Config works or am I doing something wrong? The only workaround I found is to add fetch()
inside onResume()
and call onResume() again inside onCreate()
. It results calling onResume() twice. First time by Android system and second time by code.
It there any other way to force Remote Config fetch data on first time run?
UPDATE
Inside onComplete()
first I must call firebaseRemoteConfig.activateFetched();
before getting new values from it.
onComplete()
method of the fetch listener, istask.isSuccessful()
true when fetch returns no values? If not, what istask.getException().getMessage()
? – KlaraklarikaactivateFetched()
must be called before getting new values. Yet another silly mistake... – ButterfliesactivateFetched()
is deprecated, see #57495393. Anyway, I used the solution of Mohammad Alotol. – Latifundium