Optional
controlThe control whose interaction resulted in this action being raised. Will only be present when trigger is CONTROL.
Future versions of the service will add additional controls beyond buttons, and interactions with these new
control types will also come through this one event type. For best forward-compatibility, applications should
always check the type
property of this control, and not assume that the type will always be 'button'
.
This field is marked optional as future versions of the service will also include alternate methods of raising
notification-action
events that do not originate from a button or other control.
When present, the object here will always be strictly equal to one of the control definitions within
notification
. This means indexOf
checks and other equality checks can be performed on this field if
required, such as:
function onNotificationAction(event: NotificationActionEvent): void {
if (event.control && event.control.type === 'button') {
const butttonIndex = event.notification.buttons.indexOf(event.control);
// Handle button click
// . . .
}
}
The notification that created this action
Application-defined metadata that this event is passing back to the application.
A notification-action
event is only fired for a given trigger if the
notification options included an action result for that trigger.
See the comment on the NotificationActionEvent type for an example of buttons that do and don't raise actions.
This property allows the application handling the action to identify where this notification originated.
Indicates what triggered this action.
Note that the programmatic
trigger is not yet implemented.
Generated using TypeDoc
Event fired when an action is raised for a notification due to a specified trigger. It is important to note that applications will only receive these events if they indicate to the service that they want to receive these events. See actions for a full example of how actions are defined, and how an application can listen to and handle them.
This can be fired due to interaction with notification buttons or the notification itself, the notification being closed (either by user interaction or by API call), or by the notification expiring. Later versions of the service will add additional control types that may raise actions from user interaction. All actions, for all control types, will be returned to the application via the same
notification-action
event type.The event object will contain the application-defined metadata that allowed this action to be raised, and details on what triggered this action and which control the user interacted with.
Unlike other event types,
notification-action
events will be buffered by the service until the application has added a listener for this event type, at which point it will receive all bufferednotification-action
events. The service will also attempt to restart the application if it is not running when the event is fired.This type includes a generic type argument, should applications wish to define their own interface for action results. See NotificationActionResult for details.
"notification-action"