User notifications can be generated from any component through Finsemble's Notification API.

There are two sides to notifications. Developers add notifications from within code, essentially calling on the Notification API to deliver a notification. Delivered notifications are displayed through an HTML template that a developer can customize. A system-wide default template can be installed. Developers can also specify which template to use when they send the notification. Notifications can be classified by topic.

Accessing the Notification API

Notifications are called from FSBL.UserNotification.alert.

In the following example, the message "My what a fine notification!" is sent only once. "my-tracking-identifier" is used to make sure the message is unique. In this example, the default template is overridden with the URL parameter.

    FSBL.UserNotification.alert("dev", "ONCE-SINCE-STARTUP", "my-tracking-identifier", "My what a fine notification!", {url: "/mytemplate.html"});

Setting the default template

The default notification template is located in src-built-in/components/notification/notification.html. If this is missing, a very basic built-in template is used. You can change the location of the default template in the manifest with the notificationURL parameter:

   "finsemble": {
        "applicationRoot": "https://localhost:3375",
        "moduleRoot": "https://localhost:3375/finsemble/",
        "notificationURL": "https://localhost:3375/components/notification/notification.html",

Advanced template usage

When sending a string as your notification message, the template will automatically drop the contents of the string into the .notification-description selector. You can optionally send an object as your notification containing multiple fields to replace in the template. For instance, if you wanted to set both title and description you would use the following:

    FSBL.UserNotification.alert("dev", "ONCE-SINCE-STARTUP", "my-tracking-identifier",
    { description: "My what a fine notification!", title: "Extra! Extra!" });

The .notification-description tag will be changed to "My what a fine notification!" and the .notification-title tag will be changed to "Extra! Extra!".

Further reading

For advanced information about notifications, check out the Notification API documentation.

These notifications use OpenFin's notification API.