startService method
Future<bool>
startService({
- required AndroidNotificationOptions androidNotificationOptions,
- required IOSNotificationOptions iosNotificationOptions,
- required ForegroundTaskOptions foregroundTaskOptions,
- required String notificationTitle,
- required String notificationText,
- Function? callback,
override
Implementation
@override
Future<bool> startService({
required AndroidNotificationOptions androidNotificationOptions,
required IOSNotificationOptions iosNotificationOptions,
required ForegroundTaskOptions foregroundTaskOptions,
required String notificationTitle,
required String notificationText,
Function? callback,
}) async {
if (await isRunningService == false) {
final options = Platform.isAndroid
? androidNotificationOptions.toJson()
: iosNotificationOptions.toJson();
options['notificationContentTitle'] = notificationTitle;
options['notificationContentText'] = notificationText;
if (callback != null) {
options.addAll(foregroundTaskOptions.toJson());
options['callbackHandle'] =
PluginUtilities.getCallbackHandle(callback)?.toRawHandle();
}
return await methodChannel.invokeMethod('startService', options);
}
return false;
}