Class: Notification

Notification

A Notification object represents a window on OpenFin Runtime which is shown briefly to the user on the bottom-right corner of the primary monitor. A notification is typically used to alert the user of some important event which requires his or her attention. Notifications are a child or your application that are controlled by the runtime.

Constructor
Synchronous Methods
Asynchronous Methods

NOTE: Methods annotated with "(static)" are shared methods called on the class (object constructor) itself.

Constructor

new Notification(options, callbackopt, errorCallbackopt)

Creates a new Notification.

Best practice is to invoke with the new keyword. (See notification.constructor tutorial for an example.) Failure to use the new operand will result in a console warning (but will otherwise succeed).

Parameters:
Name Type Attributes Description
options fin.desktop.Notification~options

Notification creation options. See options for more details.

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

Methods

(static) getCurrent() → {fin.desktop.Notification}

Gets an instance of the current notification. For use within a notification window to close the window or send a message back to its parent application.

Tutorials:
Returns:
Type
fin.desktop.Notification

close(callbackopt)

Closes the notification.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

Tutorials:

sendMessage(message, callbackopt)

Sends a message to the notification.

Parameters:
Name Type Attributes Description
message variable

The message to be sent to the notification. Can be either a primitive data type (string, number, or boolean) or composite data type (object, array) that is composed of other primitive or composite data types.

callback function <optional>

called if the method succeeds.

Tutorials:

sendMessageToApplication(message, callbackopt)

Sends a message from the notification to the application that created the notification. The message is handled by the notification's onMessage callback.

Parameters:
Name Type Attributes Description
message variable

The message to be sent to the application. Can be either a primitive data type (string, number, or boolean) or composite data type (object, array) that is composed of other primitive or composite data types.

callback function <optional>

called if the method succeeds.

Tutorials:

Type Definitions

onClick()

Invoked when the notification is clicked.

onClose()

Invoked when the notification is closed via close() on the notification instance. NOTE: this is not invoked when the notification is dismissed via a swipe. For the swipe dismissal callback see onDismiss.

onDismiss()

Invoked when the notification is dismissed by swiping it off the screen to the right. NOTE: this is not fired on a programmatic close.

onMessage(message)

Invoked when the notification recieves a message sent via sendMessage() on the notification instance.

Parameters:
Name Type Description
message any

The message sent to the notification via sendMessage.

onShow(successObj)

Invoked when the notification is shown.

Parameters:
Name Type Description
successObj fin.desktop.Notification~onShowSuccess

onShowSuccess

onShowSuccess

Notification success callback object.

This is returned by the success callback on a successful show.

Type:
  • object
Properties:
Name Type Description
httpResponseCode number

HTTP response code

options

Notification creation options.

This is the options object required by the Notification constructor.

Type:
  • object
Properties:
Name Type Description
ignoreMouseOver boolean

Force dismissal even if the mouse is hovering over the notification.

message any

Any serializable JavaScript value.

onClick fin.desktop.Notification~onClick

onClick

onClose fin.desktop.Notification~onClose

onClose

onDismiss fin.desktop.Notification~onDismiss

onDismiss

onError errorCallback

onError

onMessage fin.desktop.Notification~onMessage

onMessage

onShow fin.desktop.Notification~onShow

onShow

timeout number | string

The duration the notification is shown in milliseconds.

opacity number

A flag that specifies how transparent the notification will be. This value is clamped between 0.0 and 1.0.

url string

The URL for the notification.