Maybe I am missing something, but shouldn't the fetch()
be called only if the cached values are older than the cached value?
Having this code called from activity's onCreate
firebaseRC = FirebaseRemoteConfig.getInstance()
firebaseRC.fetch(3600L). .addOnCompleteListener(this, new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
//THE TASK IS ALWAYS SUCCESSFUL
firebaseRC.activateFetched();
}
}
});
If I start the app on my emulator a few times in a row, the fetch completes successfully each time.
Shouldn't the fetch
actually complete with success only if my data is older than 3600 seconds? So starting the app a second time, fetch should complete without onComplete
The docs say:
Remote Config caches values locally after the first successful fetch. By default the cache expires after 12 hours, but you can change the cache expiration for a specific fetch by passing the desired cache expiration to the fetch method. If the values in the cache are older than the desired cache expiration, Remote Config will request fresh config values from the service. If your app requests fresh values using fetch several times, requests are throttled and your app is provided with cached values.
It doesn't say how onComplete
will trigger... should I use activateFetched()
each time as it has the same value?