disableNetwork method

Future<void> disableNetwork(
  1. {@required String zoneName}
)

You can invoke this method to disable the data synchronization on the local device. After data synchronization is disabled, data will not be synchronized between the device and the cloud.

Data synchronization only controls whether to synchronize data for a single Cloud DB zone. The AGConnectCloudDB connection to the cloud is disconnected and data synchronization stops only after data synchronization is disabled for all Cloud DB zone. The synchronization function is not permanently disabled. The synchronization function is enabled by default when the application is opened again every time. Generally, the application invokes this API when detecting that the user uses a mobile data network (for example, a 4G network), so as to avoid using mobile data traffic of the user during data synchronization. Whether to disable the function depends on your network authorization.

Implementation

Future<void> disableNetwork({@required String zoneName}) async {
  if (zoneName == null || zoneName.isEmpty) {
    throw FormatException('Value of zoneName cannot be null or an empty string.', zoneName);
  }

  try {
    return await _methodChannel.invokeMethod<void>(
      MethodConstants.DISABLE_NETWORK,
      <String, dynamic>{
        KeyConstants.ZONE_NAME: zoneName,
      },
    );
  } catch (e) {
    throw AGConnectCloudDBException.from(e);
  }
}