The Notification interface of the Notifications API is used to configure and display desktop notifications to the user.

Documentation Notification by Mozilla Contributors, licensed under CC-BY-SA 2.5.

See also:

Static variables

staticread onlypermission:NotificationPermission

A string representing the current permission to display notifications. Possible values are:

denied — The user refuses to have notifications displayed. granted — The user accepts having notifications displayed. default — The user choice is unknown and therefore the browser will act as if the value were denied.

Constructor

new(title:String, ?options:Null<NotificationOptions>)

Throws:

null

DOMError

Variables

read onlybody:String

The body string of the notification as specified in the constructor's options parameter.

read onlydata:Dynamic

Returns a structured clone of the notification’s data.

read onlydir:NotificationDirection

The text direction of the notification as specified in the constructor's options parameter.

read onlyicon:String

The URL of the image used as an icon of the notification as specified in the constructor's options parameter.

read onlylang:String

The language code of the notification as specified in the constructor's options parameter.

onclick:Function

A handler for the click event. It is triggered each time the user clicks on the notification.

onclose:Function

A handler for the close event. It is triggered when the user closes the notification.

onerror:Function

A handler for the error event. It is triggered each time the notification encounters an error.

onshow:Function

A handler for the show event. It is triggered when the notification is displayed.

read onlytag:String

The ID of the notification (if any) as specified in the constructor's options parameter.

read onlytitle:String

The title of the notification as specified in the first parameter of the constructor.

Methods

close():Void

Programmatically closes a notification.

Inherited Variables

Inherited Methods

Defined by EventTarget

addEventListener(type:String, listener:Function, ?options:EitherType<AddEventListenerOptions, Bool>, ?wantsUntrusted:Bool):Void

addEventListener(type:String, listener:EventListener, ?options:EitherType<AddEventListenerOptions, Bool>, ?wantsUntrusted:Bool):Void

Register an event handler of a specific event type on the EventTarget.

Throws:

null

DOMError

dispatchEvent(event:Event):Bool

Dispatch an event to this EventTarget.

Throws:

null

DOMError

removeEventListener(type:String, listener:Function, ?options:EitherType<EventListenerOptions, Bool>):Void

removeEventListener(type:String, listener:EventListener, ?options:EitherType<EventListenerOptions, Bool>):Void

Removes an event listener from the EventTarget.

Throws:

null

DOMError