notifications.create()

Creates and displays a notification.

Pass a notifications.NotificationOptions to define the notification's content and behavior. You can optionally provide an ID for the notification. If you omit the ID, an ID will be generated. You can also pass a callback, which will be called with the notification's ID if the notification was successfully created. 

Syntax

browser.notifications.create(
  id,                    // string
  options,               // NotificationOptions
  function(id) {...}     // optional function
)

Parameters

idOptional
string. This is used to refer to this notification in notifications.update(), notifications.clear(), and event listeners. If you omit this argument or pass an empty string, then a new ID will be generated for this notification. If the ID you provide matches the ID of an existing notification from this add-on, then the other notification will be cleared.
options
notifications.NotificationOptions. Defines the notification's content and behavior.
callbackOptional
function. The function is passed the following arguments:
id
string. The notification's ID.

Browser compatibility

EdgeFirefoxChromeOpera
Basic support?45.0Yes33
Firefox
Basic support48.0

Examples

Example add-ons

Acknowledgements

This API is based on Chromium's chrome.notifications API.

Document Tags and Contributors

 Contributors to this page: wbamberg, kmaglione
 Last updated by: wbamberg,