Android Firebase Remote Config initial fetch does not return value

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.

+4
source share
3 answers

, , , . , , , .

, , , Firebase. "".

FireBases Remote Config Unity, , ActivateFetched, . , , , : https://github.com/firebase/quickstart-unity/issues/9

, RemoteConfig Unity . , .

Android

0

:

Firebase,

0

FirebaseRemoteConfig.getInstance().fetch(0).
0
mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
        FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder().build();
        mFirebaseRemoteConfig.setConfigSettingsAsync(configSettings)
                .addOnCompleteListener(task -> mFirebaseRemoteConfig.fetchAndActivate()
                        .addOnCompleteListener(activity, task1 {
                       // now cache is updated you can fetch values
                       String value = mFirebaseRemoteConfig.getString("key");
               }));

- (:              mFirebaseRemoteConfig.getString("key");)

0

Source: https://habr.com/ru/post/1650921/