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)

Anonymous
  • 223
  • 3
  • 9

1 Answers1

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.

Stoyan Milev
  • 725
  • 4
  • 17
  • 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? :) – Anonymous Feb 04 '21 at 17:43
  • So, `String object = FirebaseRemoteConfig.getInstance().getString("mobile_database"); ` this method returns only the first part of the json? – Stoyan Milev Feb 04 '21 at 18:04
  • I thought it should get the whole string? Not just the first part? – Anonymous Feb 04 '21 at 19:41
  • Maybe you have set them up as conditional parameters in your Firebase Config console. Could you check it? – Stoyan Milev Feb 04 '21 at 19:52
  • 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 it – Anonymous Feb 04 '21 at 20:29
  • 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? – Anonymous Feb 04 '21 at 20:39
  • Strange behavior indeed. Maybe you are getting updates every hour or so because you have set `.setMinimumFetchIntervalInSeconds(3600)`. – Stoyan Milev Feb 05 '21 at 08:37