Permissions: notifications

Not allowed in: Content scripts, Devtools pages

_CreateNotificationOptionsButtons
_UpdateNotificationOptionsButtons
CreateNotificationOptions
NotificationItem
UpdateNotificationOptions
PermissionLevel
TemplateType
onButtonClicked
onClicked
onClosed
onPermissionLevelChanged
onShown
onShowSettings
clear
create
getAll
getPermissionLevel
update
PermissionLevel: "granted" | "denied"
TemplateType: "basic" | "image" | "list" | "progress"
onButtonClicked: WebExtEvent<
    (notificationId: string, buttonIndex: number) => void,
>

Fired when the user pressed a button in the notification.

The notificationId of the clicked notification.

The index of the button clicked by the user.

onClicked: WebExtEvent<(notificationId: string) => void>

Fired when the user clicked in a non-button area of the notification.

The notificationId of the clicked notification.

onClosed: WebExtEvent<(notificationId: string, byUser: boolean) => void>

Fired when the notification closed, either by the system or by user action.

The notificationId of the closed notification.

True if the notification was closed by the user.

onPermissionLevelChanged:
    | WebExtEvent<(level: PermissionLevel) => void>
    | undefined

Fired when the user changes the permission level.

The new permission level.

Unsupported on Firefox at this time.

onShown: WebExtEvent<(notificationId: string) => void>

Fired when the notification is shown.

The notificationId of the shown notification.

onShowSettings: WebExtEvent<() => void> | undefined

Fired when the user clicked on a link for the app's notification settings.

Unsupported on Firefox at this time.

  • Clears an existing notification.

    Parameters

    • notificationId: string

      The id of the notification to be updated.

    Returns Promise<boolean>

  • Creates and displays a notification.

    Parameters

    Returns Promise<string>

  • Creates and displays a notification.

    Parameters

    • notificationId: string

      Identifier of the notification. If it is empty, this method generates an id. If it matches an existing notification, this method first clears that notification before proceeding with the create operation.

    • options: CreateNotificationOptions

      Contents of the notification.

    Returns Promise<string>

  • Retrieves whether the user has enabled notifications from this app or extension.

    Returns Promise<PermissionLevel>

    Unsupported on Firefox at this time.

  • Updates an existing notification.

    Parameters

    • notificationId: string

      The id of the notification to be updated.

    • options: UpdateNotificationOptions

      Contents of the notification to update to.

    Returns Promise<boolean>

    Unsupported on Firefox at this time.