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 forbodyandtitleof the system notificationtitle(string)body(string)
options(object) options to alter the behavior of the notificationsnoSystemNotification(boolean) iftruethis skips making the system notification, subsequently theclickToFocusoption will not workclickToFocus(object) used to focus on a tab when the system notification is clicked.tabId(string) - the uuid of the tab you want focused onwindowId(string) - the uuid of the window that contains the tab you want focused on
inTabNotification(object) used to define an in tab notificationuuid(object) - the uuid of the tabtitle(string) - the title of the notificationmsg(string) - the message of the notificationstyle(string) - optional style for the notification. Possible values aresuccess,normal,warn, anderror. If thestyleproperty is omitted or set to an unrecognized value, the default isnormal.
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
webContentsand also atabobject. It will create a system notification that will focus on the tab it relates to and will create an in tab notificationjancy.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 tabnotificationId(string) - the ID of the in-tab notification returned fromnotificationFactory.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);