updateBackgroundNotification function

Future<bool> updateBackgroundNotification({
  1. String? channelName,
  2. String? title,
  3. String? iconName,
  4. String? subtitle,
  5. String? description,
  6. Color? color,
  7. bool? onTapBringToFront,
})

Change options of sticky background notification on Android.

This method only applies to Android and allows for customizing the notification, which is shown when 'inBackground' is set to true.

Uses title as the notification's content title and searches for a drawable resource with the given iconName. If no matching resource is found, no icon is shown. The content text will be set to subtitle, while the sub text will be set to description. The notification color can also be customized.

When onTapBringToFront is set to true, tapping the notification will bring the activity back to the front.

Both title and channelName will be set to defaults, if no values are provided. All other null arguments will be ignored.

Returns true if the notification is currently has been properly updated

For Android SDK versions above 25, uses channelName for the 'NotificationChannel' (https://developer.android.com/reference/android/app/NotificationChannel).

Implementation

Future<bool> updateBackgroundNotification({
  String? channelName,
  String? title,
  String? iconName,
  String? subtitle,
  String? description,
  Color? color,
  bool? onTapBringToFront,
}) async {
  final response = await _platform.updateBackgroundNotification(
    channelName: channelName,
    title: title,
    iconName: iconName,
    subtitle: subtitle,
    description: description,
    color: color,
    onTapBringToFront: onTapBringToFront,
  );
  if (response == null) {
    throw Exception('Error while getting Network status');
  }
  return response;
}