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
id
Optionalstring
. This is used to refer to this notification innotifications.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.callback
Optionalfunction
. The function is passed the following arguments:-
id
string
. The notification's ID.
Browser compatibility
Examples
Example add-ons
Acknowledgements
This API is based on Chromium's chrome.notifications
API.