setReportPolicies method

Future<void> setReportPolicies({
  1. int? scheduledTime,
  2. bool? appLaunch,
  3. bool? moveBackground,
  4. int? cacheThreshold,
})

Sets data reporting policies.

Implementation

Future<void> setReportPolicies({
  int? scheduledTime,
  bool? appLaunch,
  bool? moveBackground,
  int? cacheThreshold,
}) async {
  Map<String, dynamic> policyMap = <String, dynamic>{};

  if (scheduledTime != null) {
    policyMap['scheduledTime'] = scheduledTime;
    if (scheduledTime < 60 && scheduledTime > 1800) {
      debugPrint(
        'Invalid value provided for scheduledTime. Accepted value range: [60 - 1800].',
      );
    }
  }

  if (cacheThreshold != null) {
    policyMap['cacheThreshold'] = cacheThreshold;
    if (cacheThreshold < 30 && cacheThreshold > 1000) {
      debugPrint(
        'Invalid value provided for cacheThreshold. Accepted value range: [30 - 1000]',
      );
    }
  }

  if (appLaunch != null) {
    policyMap['appLaunch'] = appLaunch;
  }

  if (moveBackground != null) {
    policyMap['moveBackground'] = moveBackground;
  }

  await _channel.invokeMethod(
    'setReportPolicies',
    <String, dynamic>{
      'policyType': policyMap,
    },
  );
}