initRemoteConf static method
Initialize the service
This functions initialize the remote configuration service and set the
defaultValues
. The function fetch the values from the server if the
app is running on release.
Set expirationTimeInHours
with the time that the functions stores the values
in cache.
Set fetchTimeout
with the time that the functions will wait if
there is a network problem during fetch.
Implementation
static Future<void> initRemoteConf(
Map<String, dynamic> defaultValues, {
int expirationTimeInHours = PauloniaRemoteConfConstants
.REMOTE_CONF_DEFAULT_EXPIRATION_TIME_IN_HOURS,
int fetchTimeout = PauloniaRemoteConfConstants
.REMOTE_CONF_DEFAULT_FETCH_TIMEOUT_IN_SECONDS,
}) async {
_remoteConfig = FirebaseRemoteConfig.instance;
_defaultValues = defaultValues;
await _remoteConfig.setDefaults(_defaultValues);
await _remoteConfig.setConfigSettings(RemoteConfigSettings(
fetchTimeout: Duration(seconds: fetchTimeout),
minimumFetchInterval: Duration(hours: expirationTimeInHours),
));
if (PUtils.isOnRelease() && (await PUtils.checkNetwork())) {
await _remoteConfig.fetch();
}
await _remoteConfig.activate();
}