Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

notifications.getAll()

この記事はまだボランティアによって 日本語 に翻訳されていません。ぜひ MDN に参加して翻訳を手伝ってください!

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 or array. 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 is true.

Browser compatibility

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"
      });
    }
  });
});

Acknowledgements

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.

ドキュメントのタグと貢献者

 このページの貢献者: Makyen, wbamberg
 最終更新者: Makyen,