Control how users clear or dismiss notifications

In older versions of Notification Center, users clicked the body of a toast to dismiss it from the desktop. In Notifications v1.17.2 or later, users click an x in the upper right corner of the notification instead. Clicking the same x in a notification in Notification Center clears it completely.

Dismissing a notification removes a toast and displays it only in Notification Center. Clearing a notification deletes it entirely from Notification Center. You should be aware of the distinction especially if you set notifications without toasts (that is, only in Notification Center).

Change default notification body interaction

You can override the default behavior and allow the user to dismiss by clicking the body of the notification. Add the following to your notification create function:

const notification = 
 onSelect: {BODY_CLICK: ActionBodyClickType.DISMISS_EVENT}

In more recent versions of Notification Center, you can add actionable elements to the body of the notification. See [Work with actionable fragments](doc:actionable fragments). If you add these elements to a notification, overriding the default dismiss behavior could create a confusing user experience.

See the Notifications API reference documentation for details.