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.
The notification looks the same on all desktop operating systems. Something like:
Types
notifications.NotificationOptions
- Defines the content of a notification.
notifications.TemplateType
- The type of notification. For example, this defines whether the notification can contain an image.
Functions
notifications.clear()
- Clear a specific notification, given its ID.
notifications.create()
- Create and display a new notification.
notifications.getAll()
- Get all notifications.
notifications.update()
- Update a notification.
Events
notifications.onButtonClicked
- Fired when the user clicked a button in the notification.
notifications.onClicked
- Fired when the user clicked the notification, but not on a button.
notifications.onClosed
- Fired when a notification closed, either by the system or because the user dismissed it.
notifications.onShown
- Fired immediately after a notification has been shown.
Browser compatibility
Desktop | Mobile | |||||
---|---|---|---|---|---|---|
NotificationOptions | Chrome Full support Yes | Edge Full support 17 | Firefox Full support 45 | Opera Full support Yes | Safari Full support 14 | Firefox Android Full support 48 |
TemplateType | Chrome Full support Yes | Edge Full support 17 | Firefox
Full support
45
| Opera
Full support
Yes
| Safari Full support 14 | Firefox Android
Full support
48
|
clear | Chrome Full support 28 | Edge Full support 17 | Firefox Full support 45 | Opera Full support 25 | Safari No support No | Firefox Android Full support 48 |
create | Chrome Full support 28 | Edge Full support 17 | Firefox Full support 45 | Opera Full support 25 | Safari No support No | Firefox Android Full support 48 |
getAll | Chrome Full support 29 | Edge Full support 17 | Firefox Full support 45 | Opera Full support 25 | Safari No support No | Firefox Android Full support 48 |
onButtonClicked | Chrome Full support 28 | Edge Full support 17 | Firefox No support No | Opera Full support 25 | Safari No support No | Firefox Android No support No |
onClicked | Chrome Full support 28 | Edge Full support 17 | Firefox Full support 47 | Opera Full support 25 | Safari No support No | Firefox Android Full support 48 |
onClosed | Chrome Full support 28 | Edge Full support 17 | Firefox Full support 45 | Opera Full support 25 | Safari No support No | Firefox Android Full support 48 |
onShown | Chrome No support No | Edge No support No | Firefox Full support 56 | Opera No support No | Safari No support No | Firefox Android Full support 56 |
update | Chrome Full support 28 | Edge Full support 17 | Firefox No support No | Opera
Full support
25
| Safari No support No | Firefox Android No support No |
Legend
- Full support
- Full support
- No support
- No support
- See implementation notes.
- See implementation notes.
Example extensions
Acknowledgements
This API is based on Chromium's chrome.notifications
API.