Skip to main content Link Search Menu Expand Document (external link)

The Notification Factory Interface

With the Notification Factory you can create either a system notification or an in tab notification.

There is only one notification factory interface and it can always be found at jancy.notificationFactory.

Methods

notificationFactory.create(notificationOptions, options)

Create a notification.

  • notificationOptions (object) options to override the defaults used by the factory for body and title of the system notification
    • title (string)
    • body (string)
  • options (object) options to alter the behavior of the notifications
    • noSystemNotification (boolean) if true this skips making the system notification, subsequently the clickToFocus option will not work
    • clickToFocus (object) used to focus on a tab when the system notification is clicked.
      • tabId (string) - the uuid of the tab you want focused on
      • windowId (string) - the uuid of the window that contains the tab you want focused on
    • inTabNotification (object) used to define an in tab notification
      • uuid (object) - the uuid of the tab
      • title (string) - the title of the notification
      • msg (string) - the message of the notification
      • style (string) - optional style for the notification. Possible values are success, normal, warn, and error. If the style property is omitted or set to an unrecognized value, the default is normal.

Returns the unique ID of the notification as a string but only if an inTabNotification object was specified in the options passed in.

In this example you have to have a tab’s webContents and also a tab object. It will create a system notification that will focus on the tab it relates to and will create an in tab notification

     jancy.notificationFactory.create({
       title: 'Update',
       body: "This is a message",
     },
     {
       inTabNotification: {
         uuid: tab.uuid,
         title: "Notification", 
         msg:"HEEEY",
         style: "success"
       },
       clickToFocus: {
         tabId: tab.uuid,
         windowId: tab.parentWindowId 
       }
     })

notificationFactory.dismissNotification(uuid, notificationId)

Dismiss an in-tab notification by tab ID and notification ID.

  • uuid (string) - the uuid of the tab
  • notificationId (string) - the ID of the in-tab notification returned from notificationFactory.create()
 const notificationID = jancy.notificationFactory.create({
     title: 'Update',
     body: "This is a message",
   },
   {
     inTabNotification: {
       uuid: tab.uuid,
       title: "Notification", 
       msg:"HEEEY",
       style: "success"
     },
     clickToFocus: {
       tabId: tab.uuid,
       windowId: tab.parentWindowId 
     }
   }
 );
 // Later on...
 jancy.notificationFactory.dismissNotification(tab.uuid, notificationID);