scheduleBackgroundTask method

Future<void> scheduleBackgroundTask({
  1. required String taskId,
  2. required Duration delay,
  3. Map<String, dynamic>? data,
})

Schedule a background task

Implementation

Future<void> scheduleBackgroundTask({
  required String taskId,
  required Duration delay,
  Map<String, dynamic>? data,
}) async {
  try {
    await methodChannel.invokeMethod<void>('scheduleBackgroundTask', {
      'taskId': taskId,
      'delayMillis': delay.inMilliseconds,
      'data': data,
    });
  } on PlatformException catch (e) {
    throw MCPBackgroundExecutionException(
        'Failed to schedule task: ${e.message}', e.details);
  }
}