NotificationRequest

A NotificationRequest object can be used to present a non-interruptive notification to the user.

The NotificationRequest class is not subclassable.

Class Methods

constructor([identifier])

Creates a NotificationRequest object with an optional identifier.

The identifier argument can be used to assign a specific meaning to the notification, so that it may be cancelled or handled in a specific way when receiving a response. If no identifier is specified, a random string will be used.

To request a notification be presented to the user, create a NotificationRequest object, set its properties, and add it to the global NotificationCenter object. This will return a Promise, which can be used to observe when the notification is dismissed or fails. If the promise succeeds, it will provide a NotificationResponse object as the result.

Dispatching multiple notification requests with an identifier will automatically cancel any previous requests with the same identifier. Only one notification for the identifier may be displayed to the user at a time. In addition, multiple notifications sent from the same extension may be coalesced or queued to prevent overwhelming notification display.

let request = new NotificationRequest("foobar-not-found");

request.title = nova.localize("Foobar Not Found");
request.body = nova.localize("Enter the path to the foobar tool.");

request.type = "input";
request.actions = [nova.localize("OK"), nova.localize("Ignore")];

let promise = nova.notifications.add(request);
promise.then(reply => {
    console.log(reply);
}, error => {
    console.error(error);
});

Properties

identifier

The identifier for the notification.

This property is settable.

title

The title to be displayed to the user. This should be short and concise, and localized if possible.

This property is settable.

body

The body of the notification displayed to the user. This should be localized, if possible.

This property is settable.

type

A string denoting the type of notification to display. By default, this will be a simple informative notification (with no input boxes).

The following types are supported:

This property is settable.

textInputValue

The default value of the input field, for notifications of the appropriate type.

This property is settable.

textInputPlaceholder

The placeholder value of the input field, for notifications of the appropriate type.

This property is settable.

actions

The set of actions to display to the user, as an array of strings. These should be localized, if possible.

This property is settable.