FirebaseRemoteConfig getString is empty
Asked Answered
U

1

1

hey guys I was having a problem with firebase remote config basically the part I blurred out has a json array that looks like this:

 [
      {
        "owner": "1",
        "platform": "android"
      },
      {
        "owner": "2",
        "platform": "ios"
      }
 ]

and then in the "onCreate" method in java I used this code here:

mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
configSettings = new FirebaseRemoteConfigSettings.Builder()
    .setMinimumFetchIntervalInSeconds(3600)
    .build();
mFirebaseRemoteConfig.setConfigSettingsAsync(configSettings);

and when I try to get the value as a string with this code:

String object = FirebaseRemoteConfig.getInstance().getString("mobile_database");

if I go in debug mode it shows that object = "" it's just an empty string is there anything that I am doing wrong?

I tried making research but I can't find anything useful?

Thanks in advance :)

PS (before someone marks it as duplicate these links did not help me :D

Is there a way to create an audience of developer builds?

getString Outside of a Context or Activity

FirebaseRemoteConfig getString returns empty but bytearray of remote config is not empty)

Ulcerate answered 4/2, 2021 at 15:15 Comment(1)
Have you tried to set your minimumFetchIntervalInSecodns to 0 and restart your app?Pylle
B
1

You are not calling the fetch method so the RemoteConfig is falling back to your local config if you have set one. See how to fetch and activate values.

Blocker answered 4/2, 2021 at 16:36 Comment(7)
Hey! Thanks for that I overlooked that part. Now it does the request fine, but it only gets the first object in the json, do you have any idea why that could be? :)Ulcerate
So, String object = FirebaseRemoteConfig.getInstance().getString("mobile_database"); this method returns only the first part of the json?Blocker
I thought it should get the whole string? Not just the first part?Ulcerate
Maybe you have set them up as conditional parameters in your Firebase Config console. Could you check it?Blocker
I just checked, and to create the value I only clicked on the "Add Parameter" button, entered the key and value, and clicked "add parameter" again. That's pretty weird isn't itUlcerate
Ohh I good news! It gets the data correctly now! I think it updates every hour or so, I remember reading something about throttling, do you think that's the reason? How can I change this behaviour? Like I want to fetch the data as soon as the user opens the app, is that possible?Ulcerate
Strange behavior indeed. Maybe you are getting updates every hour or so because you have set .setMinimumFetchIntervalInSeconds(3600).Blocker

© 2022 - 2024 — McMap. All rights reserved.