Skip to main content

NotificationAction

Button attached to a notification.

Selections are reported through Notifications.on_action, with id in NotificationActionEvent.action_id.

For inline replies, set input. Reply text is available in NotificationActionEvent.input.

Note

Windows also returns input values in the event's inherited data mapping.

Properties

  • cancel_notification - Whether to dismiss the notification when this action is selected.
  • destructive - Whether to style the action as destructive.
  • foreground - Whether selecting the action brings the app to the foreground.
  • id - Nonempty identifier returned when the action is selected.
  • input - Reply input associated with this action.
  • require_authentication - Whether the user must unlock the device before the action runs.
  • title - Nonempty button label displayed by the operating system.

Properties​

cancel_notificationclass-attributeinstance-attribute​

cancel_notification: bool = True

Whether to dismiss the notification when this action is selected.

Note

Supported only on Android.

destructiveclass-attributeinstance-attribute​

destructive: bool = False

Whether to style the action as destructive.

This changes presentation, not the action's behavior.

Note

Supported only on iOS and macOS.

foregroundclass-attributeinstance-attribute​

foreground: bool = True

Whether selecting the action brings the app to the foreground.

Note

Supported only on Android, iOS, and macOS. With False, those platforms may queue the event for replay when the service next initializes. Python handlers do not execute inside the background isolate.

Windows actions use dismiss activation regardless of this flag. Linux ignores this flag and reports the action only while the app is running. Web ignores this flag; the upstream service worker delivers the click to an open app window or opens the app if none is available.

idinstance-attribute​

id: str

Nonempty identifier returned when the action is selected.

Choose distinct IDs within a notification so handlers can distinguish its buttons.

Note

Windows also uses this ID to identify an associated input.

inputclass-attributeinstance-attribute​

input: NotificationActionInput | None = None

Reply input associated with this action.

Note

Supported only on Android, iOS, macOS, and Windows. On Linux and Web, the action remains a regular button without a reply input.

require_authenticationclass-attributeinstance-attribute​

require_authentication: bool = False

Whether the user must unlock the device before the action runs.

Use it for actions with consequences, such as deleting or paying.

Note

Supported only on iOS and macOS.

titleinstance-attribute​

title: str

Nonempty button label displayed by the operating system.

Note

On Linux, the desktop's notification server decides whether buttons appear. On Web, browser and operating-system support determine whether buttons appear and how many can be shown. See browser notification action support. Keep essential actions available in the app as well.