initRemoteConf static method

Future<void> initRemoteConf(
  1. Map<String, dynamic> defaultValues, {
  2. int expirationTimeInHours = PauloniaRemoteConfConstants.REMOTE_CONF_DEFAULT_EXPIRATION_TIME_IN_HOURS,
  3. int fetchTimeout = PauloniaRemoteConfConstants.REMOTE_CONF_DEFAULT_FETCH_TIMEOUT_IN_SECONDS,
})

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();
}