Search code examples
androidfirebasefirebase-remote-config

What is the exact difference between setMinimumFetchIntervalInSeconds and fetch(long minimumFetchIntervalInSeconds)


There are two minimumFetchIntervalInSecondses in FirebaseRemoteConfig.

  1. FirebaseRemoteConfigSettings.Builder.setMinimumFetchIntervalInSeconds(long duration)
  2. FirebaseRemoteConfig.fetch(long minimumFetchIntervalInSeconds)

What is the exact difference between them other than the priorities explained in the document? Should I use both of them or to use either one of them is sufficient?

mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();

FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings
        .Builder()
        .setMinimumFetchIntervalInSeconds(mCacheExpiration) // <-- (1)
        .build();
mFirebaseRemoteConfig.setConfigSettingsAsync(configSettings);

mFirebaseRemoteConfig.fetch(mCacheExpiration); // <-- (2)

Solution

  • if you use setMinimumFetchIntervalInSeconds you can later just call mFirebaseRemoteConfig.fetch() without specificying an expiration. It will then use the one you specified before. See also here

    fetch(long minimumFetchIntervalInSeconds)

    Starts fetching configs, adhering to the specified minimum fetch interval.

    fetch()

    Starts fetching configs, adhering to the default minimum fetch interval.

    And notice that here it does in fact say that

    The default minimum fetch interval can be set with FirebaseRemoteConfigSettings.Builder#setMinimumFetchIntervalInSeconds(long)