startService static method

Future<bool> startService({
  1. required String notificationTitle,
  2. required String notificationText,
  3. Function? callback,
})

Start the foreground service with notification.

Implementation

static Future<bool> startService({
  required String notificationTitle,
  required String notificationText,
  Function? callback,
}) {
  if (_initialized == false) {
    throw const ForegroundTaskException(
        'Not initialized. Please call this function after calling the init function.');
  }

  return FlutterForegroundTaskPlatform.instance.startService(
    androidNotificationOptions: _androidNotificationOptions,
    iosNotificationOptions: _iosNotificationOptions,
    foregroundTaskOptions: _foregroundTaskOptions,
    notificationTitle: notificationTitle,
    notificationText: notificationText,
    callback: callback,
  );
}