updateNotificationText static method

Future<void> updateNotificationText({
  1. String? title,
  2. String? msg,
  3. String? bigMsg,
})

Updates the notification text displayed while tracking in the background on Android.

This method allows you to dynamically update the notification title and message that appears in the notification drawer while the app is tracking location in the background. This is Android-specific and has no effect on iOS.

Parameters:

  • title: Optional new notification title. If null, the current title is unchanged.
  • msg: Optional new notification message. If null, the current message is unchanged.
  • bigMsg: Optional new expanded notification message. If null, the current expanded message is unchanged.

Example:

await BackgroundLocator.updateNotificationText(
  title: 'Tracking Active',
  msg: 'Your location is being tracked',
);

Implementation

static Future<void> updateNotificationText(
    {String? title, String? msg, String? bigMsg}) async {
  final Map<String, dynamic> arg = {};

  if (title != null) {
    arg[Keys.SETTINGS_ANDROID_NOTIFICATION_TITLE] = title;
  }

  if (msg != null) {
    arg[Keys.SETTINGS_ANDROID_NOTIFICATION_MSG] = msg;
  }

  if (bigMsg != null) {
    arg[Keys.SETTINGS_ANDROID_NOTIFICATION_BIG_MSG] = bigMsg;
  }

  await _channel.invokeMethod(Keys.METHOD_PLUGIN_UPDATE_NOTIFICATION, arg);
}