Gets the set of all current notifications created by the add-on.
Syntax
chrome.notifications.getAll( function(notifications) {...} )
This API is also available as browser.notifications.getAll()
in a version that returns a promise.
Parameters
callback
function
. The function is passed the following arguments:-
notifications
object
orarray
. In Firefox this is an array of strings, each of which is the ID of a currently active notification. In Chrome it is an object with one property for each active notification, whose name is the ID of that notification and whose value istrue
.
Browser compatibility
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Chrome | Edge | Firefox | Firefox for Android | Opera | |
---|---|---|---|---|---|
Basic support | Yes | No | 45.0 | 48.0 | 33 |
Examples
This example shows a notification when the user clicks a browser action, unless the notification was already being shown, in which case it clears the notification. It uses getAll() to figure out whether the notification is being shown:
var myNotification = "my-notification"; chrome.browserAction.onClicked.addListener(function () { chrome.notifications.getAll((all) => { if (myNotification in all) { chrome.notifications.clear(myNotification); } else { chrome.notifications.create(myNotification, { "type": "basic", "iconUrl": chrome.extension.getURL("icons/cake-48.png"), "title": "Am imposing title", "message": "Some interesting content" }); } }); });
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.