Notification

Overview

Creates a new notification. Notifications are small two-three line notifications about an event that may have happened. The user is given a short period to respond to the notification before it disappears. The notification may have a specific call to action. This is useful to let the user know about new developments, for example in a mail application this may show a new message that arrived, the text could have the subject line, the specific CTA may be "Trash" or "Delete" while clicking anywhere in the notification would open the email.

Ancestors

  1. None
 

Descendants

  1. None
 

See Also

  1. None

Constructors

new Notification
Description

Creates a new notification that is initially hidden and not shown.

Definition

new Notification()

Members

buttonLabel
Description

Gets or sets the text label for the call-to-action button. This is optional, and if left blank removes the button from the notification.

Definition

string notification.buttonLabel
sound
Description

Gets or sets whether the system should play a default attention system sound when the notification happens. The default for this is false. Note that sound may not play depending on the user preferences set on the operating system.

Definition

boolean notification.sound
subtitle
Description

Gets or sets the sub-title for the notification. This should be a very short message, less than 10 words.

Definition

string notification.subtitle
text
Description

Gets or sets the text in the notification, this can hold, on average, up to 25 words.

Definition

string notification.text
title
Description

Gets or sets the title for the notification. This should be a very short message, less than 10 words.

Definition

string notification.title

Methods

dispatch()
Description

Dispatches the notification and shows it. Once dispatched there is no way to cancel to notification from showing. This method returns false if the notification failed to show (see requestPermission).

Definition

notification.dispatch()
Returns
TypeDescription
boolean
requestPermission(callback)
Description

This method requests permission to use notifications from the underlying operating system. At the moment this always returns true unless there is an explicit ban on the application pushing notifications (perhaps it was done too often or the user has explicitly set them not to show in the system preferences). This method is static and does not require creating a notification object. It also is not required to be used prior to creating a notification.

Definition

notification.requestPermission(callback)
Parameters
NameTypeDescription
callback function A function to callback as to the result of the request. The function will be passed on parameter that is either true or false.