Class

NotificationManager

NotificationManager

Notification manager. Access the instance using Notifications.

Extends

  • EventEmitter

Members

number

# static defaultTimeout

Default timeout in milliseconds for the notifications
Default Value:
  • 8000
number

# static defaultTimeout

Default timeout in milliseconds for the notifications
Default Value:
  • 8000
"notificationAdded" | "notificationDismissed" | "beforeAddNotification"

# static exports.NotificationEvent

List of Notification events
Properties:
Name Type Description
notificationAdded "notificationAdded" Notification added
notificationDismissed "notificationDismissed" Notification dismissed
beforeAddNotification "beforeAddNotification" Before notification is added
"information" | "success" | "warning" | "error"

# static readonly exports.NotificationType

NotificationType
Properties:
Name Type Description
information "information" Information notification
success "success" Success notification
warning "warning" Warning notification
error "error" Error notification
Array.<NotificationManager.Notification>

# readonly activeNotifications

Array of active notifications
Array.<NotificationManager.Notification>

# readonly activeNotifications

Array of active notifications
NotificationManager.DefaultNotificationHandlers

# readonly handlers

Registered notification handlers
NotificationManager.DefaultNotificationHandlers

# readonly handlers

Registered notification handlers
Map.<string, NotificationManager.Notification>

# readonly registeredNotifications

Map of registered notifications
Map.<string, NotificationManager.Notification>

# readonly registeredNotifications

Map of registered notifications

Methods

# dismissAll()

Dismiss all the active notifications

# dismissNotification(notification) → {void}

Dismiss notifications
Parameters:
Name Type Description
notification NotificationManager.Notification The notification to be dismissed
  • NotificationManager#event:notificationDismissed
void

# dismissNotificationById(id)

Dismiss notifications with the id
Parameters:
Name Type Description
id string The id of the notification(s) to be dismissed

# isNotificationHandlerEnabled() → {boolean}

Returns whether the notification handler for the given id is enabled or not
whether the notification handler is enabled or not
boolean

# registerHandler(handler)

Register notification handler. Use to expose your notification handler.
Parameters:
Name Type Description
handler NotificationManager.NotificationHandler Notification handler

# registerNotification(notification)

Register notification
Parameters:
Name Type Description
notification NotificationManager.Notification The notification to be registered
Example
Notification.registerNotification({
   id: "newNotification",
   closeButton: true,
   content: "New Notification handler",
   timeout: 0,
   type: NotificationType.warning,
   actions: [
     <NotificationBar.Action label="Hello" onClick={(event, notification) => {}} icon="Bell" />, // using the action component.
     <button type="button" onClick={(event, notification) => {}}>Hello world</button> // using custom action button
   ]
});

# showNotification(id, contextopt) → {NotificationManager.Notification|null}

Show an instance of registered notification
Parameters:
Name Type Attributes Description
id string The id of the notification to be shown
context Object <optional>
A context to be rendered in the notification
  • NotificationManager#event:notificationAdded
  • NotificationManager#event:beforeAddNotification
notification instance, can be used to dismiss later. `null` is returned if action was not shown.

# toggleNotificationHandler(id, enabled) → {void}

Enable or disable notification handler
Parameters:
Name Type Description
id NotificationManager.NotificationHandlerType of the notification handler
enabled boolean whether or not to enable or disable the handler
void

Type Definitions

# BrowserNotificationOptions

Notification options for the browser notification handler

# DefaultNotificationHandlers

Default notification handlers
Properties:
Name Type Description
browser NotificationHandler Browser notification handler
inapp NotificationHandler In-app notification handler

# Notification

Properties:
Name Type Attributes Description
id string The id for the notification
content React.ReactText | React.ReactElement.<NotificationManager.NotificationContentProps> <optional>
A content for the in-app notification. In-app notification is not shown if value is falsy.
type NotificationManager.NotificationType <optional>
The type of the notification
backgroundColor string <optional>
Define the notification background color
icon string <optional>
An optional icon to be rendered inside the notification message
timeout number <optional>
If set, it will dismiss the notification after a certain time
closeButton boolean <optional>
Show a close button
context Object <optional>
Optional context for the notification
isApplicable NotificationManager.NotificationIsApplicableFunction <optional>
callback determining whether particular notification instance should be shown
options NotificationManager.NotificationOptions <optional>
Options for the notification handlers

# NotificationCancelFunction() → {void}

Callback to cancel showing the notification.
void

# NotificationClickFunction(event) → {void}

Parameters:
Name Type Description
event any click event
void

# NotificationContentProps

Properties of the Notification
Properties:
Name Type Attributes Description
notificationContext Object <optional>
A optional context for the Notification

# NotificationEventListener(notification, cancel)

Parameters:
Name Type Description
notification NotificationManager.Notification The subject of the notification event. Mutate it to modify the notification properties.
cancel NotificationManager.NotificationCancelFunction Cancel the event
NotificationManager.DefaultNotificationHandlerType | string

# NotificationHandlerType

Notification handler type

# NotificationIsApplicableFunction(notificationInstance) → {boolean}

Parameters:
Name Type Description
notificationInstance NotificationManager.Notification instance of notification to be shown
determines whether particular instance should be shown
boolean

# NotificationOptions

Notification options for handlers
Properties:
Name Type Description
browser NotificationManager.BrowserNotificationOptions Browser notification options

Events

# beforeAddNotification

Event fired before notification is added
Parameters:
Name Type Description
notification NotificationManager.Notification Notification to be added
cancelFunction NotificationManager.NotificationCancelFunction Function to invoke to cancel the notification

# notificationAdded

Notification Added Event
Parameters:
Name Type Description
notification NotificationManager.Notification Added notification

# notificationDismissed

Notification Dismissed Event
Parameters:
Name Type Description
notification NotificationManager.Notification Dismissed notification