Welcome to OpenFin Docs

Explore our guides, resources and references for building with OpenFin

Get Started

Persistent notifications

If a notification toast contains very important information, It can be useful to make it stay visible on the desktop until the user interacts with it. Toasts that do this are called "persistent." However, you should use this capability sparingly, to avoid annoying the user with too many persistent toasts.

Image showing stack of persistent toasts on desktop, with badgingImage showing stack of persistent toasts on desktop, with badging

Image showing stack of persistent toasts on desktop, with badging

User story

Suppose your management has given you the following user stories to implement:

  1. As the head of a trade desk, I want to ensure that traders who are interested in Wayne Enterprises see any relevant news, so that they can stay up to date on current performance and can take action in a timely manner.

  2. As a user of a financial desktop, I want to ensure that I do not miss notifications from important sources amid all the things vying for my attention, so that I can take action about them.

Recipe

To make a toast persistent, you can use the sticky value of the sticky configuration option; the default value is transient.

To ensure that users understand the reason for a toast being persistent, you must also use the indicator option to signal to the user about the type of event that the toast is about. See the recipe to show the urgency of a notification for more details.

Code example

const notification = {
   "title": "Stop Loss of 47.22 for Brent Oil Futures reached",
   "category": "Trade",
   "body": "Your stop limit for Brent Oil has been reached. Proceed with the purchase of 1000 Futures?",
   "icon": "http://cdn.openfin.co/examples/notifications/company-T.png",
   "sticky": "sticky",
   "indicator": {
       "text": "Stop Limit Reached",
       "type": "warning"
   },
   "buttons": [
       {
           "title": "Buy Now",
           "type": "button",
           "cta": true, //makes the button prominent by coloring it blue
           "onClick": {
               "task": "buy-threshhold-stock",
               "customData": {
                   "message": "Example data to send back when this entry is clicked"
               }
           }
       },
       {
           "title": "Cancel Order",
           "type": "button",
       }
   ]
};
 
 create(notification);

More info

Users can turn off notifications from your app. In future releases, users may be able to turn off persistence of toasts from your app. Therefore, it is not guaranteed that a toast you specify as sticky will always be displayed or be persistent.

Updated 3 months ago


Persistent notifications


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.