updateService static method
Update the foreground service.
Implementation
static Future<bool> updateService({
String? notificationTitle,
String? notificationText,
Function? callback,
}) async {
// If the service is not running, the update function is not executed.
if (!await isRunningService) return false;
final options = <String, dynamic>{};
options['notificationContentTitle'] = notificationTitle;
options['notificationContentText'] = notificationText;
if (callback != null) {
options['callbackHandle'] =
PluginUtilities.getCallbackHandle(callback)?.toRawHandle();
}
final bool result =
await _methodChannel.invokeMethod('updateForegroundService', options);
if (result) {
_printMessage('FlutterForegroundTask has updated.');
return true;
}
return false;
}