Display notifications to the user, using the underlying operating system's notification mechanism. Because this API uses the operating system's notification mechanism, the details of how notifications appear and behave may differ according to the operating system and the user's settings.
To use this API you need to have the "notifications" permission.
Types
notifications.TemplateType
- The type of notification. For example, this defines whether the notification can contain an image.
notifications.NotificationOptions
- Defines the content of a notification.
Functions
notifications.create()
- Create and display a new notification.
notifications.update()
- Update a notification.
notifications.clear()
- Clear a specific notification, given its ID.
notifications.getAll()
- Get all notifications.
Events
notifications.onClosed
- Fired when a notification closed, either by the system or because the user dismissed it.
notifications.onClicked
- Fired when the user clicked the notification, but not on a button.
notifications.onButtonClicked
- Fired when the user clicked a button in the notification.
Browser compatibility
Chrome | Edge | Firefox | Firefox for Android | Opera | |
---|---|---|---|---|---|
NotificationOptions | Yes | No | 45 * | 48 * | Yes |
TemplateType | Yes | No | 45 * | 48 * | Yes * |
clear | Yes | No | 45 | 48 | Yes |
create | Yes | No | 45 | 48 | Yes |
getAll | Yes | No | 45 | 48 | Yes |
onButtonClicked | Yes | No | No | No | Yes |
onClicked | Yes | No | 47 | 48 | Yes |
onClosed | Yes | No | 45 * | 48 * | Yes |
update | Yes | No | No | No | Yes * |
The "Chrome incompatibilities" section is included from https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities using the WebExtChromeCompat macro.
If you need to update this content, edit https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities, then shift-refresh this page to see your changes.
Chrome incompatibilities
notifications
- For
notifications.create(), with the "basic"
type
,iconUrl
is optional in Firefox. It is required in Chrome. - Notifications are cleared immediately when the user clicks on them. This is not the case in Chrome.
- If you call
notifications.create()
more than once in rapid succession, Firefox may end up not displaying any notification at all. Waiting to make subsequent calls until within thechrome.notifications.create() callback
function is not a sufficiently long delay to prevent this from happening.
Example extensions
This API is based on Chromium's chrome.notifications
API.
Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.