# notifications Documentation: [Chrome Notifications API](https://developer.chrome.com/docs/extensions/reference/notifications) A promise-based wrapper for the Chrome `notifications` API to create and manage desktop notifications. ## Methods - [clearNotification(notificationId)](#clearNotification) - [createNotification(options, notificationId?)](#createNotification) - [getAllNotifications()](#getAllNotifications) - [getNotificationPermissionLevel()](#getNotificationPermissionLevel) - [updateNotification(options, notificationId)](#updateNotification) - [isAvailableNotifications()](#isAvailableNotifications) - [clearAllNotifications()](#clearAllNotifications) ## Events - [onNotificationsButtonClicked(callback)](#onNotificationsButtonClicked) - [onNotificationsClicked(callback)](#onNotificationsClicked) - [onNotificationsClosed(callback)](#onNotificationsClosed) - [onNotificationsPermissionLevelChanged(callback)](#onNotificationsPermissionLevelChanged) --- ### clearNotification ``` clearNotification(notificationId: string): Promise ``` Clears the notification with the specified ID, resolving to `true` if the notification existed and was cleared. ### createNotification ``` createNotification( options: chrome.notifications.NotificationOptions, notificationId?: string ): Promise ``` Creates a notification with the given options and optional ID, returning the notification ID. ### getAllNotifications ``` getAllNotifications(): Promise ``` Retrieves all currently displayed notifications. The returned object maps notification IDs to `true` values, as provided by `chrome.notifications.getAll`. ### getNotificationPermissionLevel ``` getNotificationPermissionLevel(): Promise ``` Gets the current permission level for notifications (e.g., `"granted"` or `"denied"`). ### updateNotification ``` updateNotification( options: chrome.notifications.NotificationOptions, notificationId: string ): Promise ``` Updates an existing notification with new options, resolving to `true` if the notification was updated. ### isAvailableNotifications ``` isAvailableNotifications(): boolean ``` Returns `true` if the `chrome.notifications` API is available in the current environment, otherwise `false`. ### clearAllNotifications ``` clearAllNotifications(): Promise ``` Clears all currently displayed notifications. ### onNotificationsButtonClicked ``` onNotificationsButtonClicked( callback: (notificationId: string, buttonIndex: number) => void ): () => void ``` Adds a listener for when a button on a notification is clicked. Returns an unsubscribe function. ### onNotificationsClicked ``` onNotificationsClicked( callback: (notificationId: string) => void ): () => void ``` Adds a listener for when a notification itself is clicked. Returns an unsubscribe function. ### onNotificationsClosed ``` onNotificationsClosed( callback: (notificationId: string, byUser: boolean) => void ): () => void ``` Adds a listener for when a notification is closed, including whether it was closed by the user. Returns an unsubscribe function. ### onNotificationsPermissionLevelChanged ``` onNotificationsPermissionLevelChanged( callback: (level: chrome.notifications.PermissionLevel) => void ): () => void ``` Adds a listener for changes to the notifications permission level. Returns an unsubscribe function.