Path: blob/main/files/en-us/mozilla/add-ons/webextensions/api/notifications/update/index.md
6555 views
------{{AddonSidebar()}}
Updates a notification, given its ID.
This is an asynchronous function that returns a Promise.
Syntax
Parameters
id:
string. The ID of the notification to update. This is the same as the ID passed into {{WebExtAPIRef('notifications.create()')}}'s callback.
options: {{WebExtAPIRef('notifications.NotificationOptions')}}. Defines the notification's new content and behavior.
Return value
A Promise that will be fulfilled with a boolean: true if the notification was updated, or false if it was not (for example, because the notification referenced by id did not exist).
Browser compatibility
{{Compat}}
Examples
This example uses update() to update a progress notification. Clicking the browser action shows the notification and starts an {{WebExtAPIRef("alarms", "alarm")}}, which we use to update the notification's progress indicator.
Note that you'll need the "alarms" permission to create alarms (as well as the "notifications" permission to create notifications). Also note that Firefox does not support the progress attribute.
{{WebExtExamples}}
Note: This API is based on Chromium's
chrome.notificationsAPI.