Do defaults need to be supplied for Firebase RemoteConfig?

5.8k views Asked by At

Supplying defaults is one of the steps when using RemoteConfig. It usually looks something like this:

let sefaults: [String: NSObject] = [
        "key1" : "value1" as NSObject,
        "key2" : "value2" as NSObject
    ]
FIRRemoteConfig.remoteConfig().setDefaults(defaults)

I've found RemoteConfig works perfectly fine without the above. Is the above necessary? Also, what is it doing? Seems to be a no-op.

1

There are 1 answers

2
riggaroo On BEST ANSWER

No it is not necessary to provide defaults. However, if you don't your app will use the static default of the type you have defined (the static default value of a string, a boolean etc)

The way in which Firebase Remote Config decides on a value can be described as follows:

  • First it checks if there is a cached value that was stored from the server, if there is it uses that.
  • If there is no cached value, it looks to the defaults defined either programmatically or in the defaults file. (When you call setDefaults())
  • If there is no value cached from the server, and no value in defaults, it uses the system default for that type. So even though it might not look like it is used to you, you should test your app with a clean installation and no internet to determine if its working as expected.

More info can be found here : https://firebase.google.com/docs/remote-config/ Firebase Remote Config Default Values Decision Making