actions property

List<String>? actions
getter/setter pair

Declare click listeners for <Button /> elements of a custom notification layout.

ℹ️ See Android Custom Notification Layout for setup instructions.

You can declare your own custom <Button /> elements and register click-listeners upon them using the actions parameter:

<Button
    android:id="@+id/notificationButtonPause" // <-- notificationButtonPause
    style="@style/Widget.AppCompat.Button.Small"
    android:layout_width="60dp"
    android:layout_height="40dp"
    android:text="Foo" />

Register listeners for your button using notification.actions:

Example

BackgroundGeolocation.ready(Config(
  notification: Notification(
    actions: [  // <-- register button listeners
      "notificationButtonPause"
    ]
  )
));

// Listen to custom button clicks:
BackgroundGeolocation.onNotificationAction((String buttonId) {
  print("[onNotificationAction] - ${buttonId}");
  switch(buttonId) {
    case 'notificationButtonPause':
      BackgroundGeolocation.changePace(false);
      break;
  }
});

Implementation

List<String>? actions;