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.
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 = TrueWhether to dismiss the notification when this action is selected.
Supported only on Android.
destructiveclass-attributeinstance-attribute
destructive: bool = FalseWhether to style the action as destructive.
This changes presentation, not the action's behavior.
Supported only on iOS and macOS.
foregroundclass-attributeinstance-attribute
foreground: bool = TrueWhether selecting the action brings the app to the foreground.
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: strNonempty identifier returned when the action is selected.
Choose distinct IDs within a notification so handlers can distinguish its buttons.
Windows also uses this ID to identify an associated input.
inputclass-attributeinstance-attribute
input: NotificationActionInput | None = NoneReply input associated with this action.
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 = FalseWhether the user must unlock the device before the action runs.
Use it for actions with consequences, such as deleting or paying.
Supported only on iOS and macOS.
titleinstance-attribute
title: strNonempty button label displayed by the operating system.
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.