enableNetwork method

Future<void> enableNetwork({
  1. required String zoneName,
})

You can invoke this method to open the data synchronization on the local device. Data can be synchronized between the device and the cloud only after data synchronization is enabled.

After AGConnectCloudDB initialization, device-cloud data synchronization of all Cloud DB zone is opened by default and does not need to be explicitly invoked by applications. Generally, you can invoke this method when you use Wi-Fi and the network status is good. If you use the mobile data network to invoke this API, the specific operation depends on your network authorization. After the data synchronization function is opened on the local device, the device checks whether there is any data that is not synchronized. If there is any data that is not synchronized, the device-cloud data synchronization is triggered.

Implementation

Future<void> enableNetwork({
  required String zoneName,
}) async {
  if (zoneName.isEmpty) {
    throw FormatException('zoneName cannot be an empty string.', zoneName);
  }
  try {
    return await _methodChannel.invokeMethod<void>(
      _MethodConstants.ENABLE_NETWORK,
      <String, dynamic>{
        _KeyConstants.ZONE_NAME: zoneName,
      },
    );
  } catch (e) {
    throw AGConnectCloudDBException._from(e);
  }
}