Notifications Module

Required Permissions: slobs.notifications

This module can be used to push notifications to the Streamlabs OBS native UI, mark your notifications as read and bind a callback action for when your notification has been read. We will add more functionality to this module as requested.

Minimum Version

This was module was added in Build 7 of the Streamlabs OBS App Developer build.

NotificationOptions object

The NotificationOptions object represents the data structure of a new notification to be pushed.

PropertyTypeDescription
messagestringThe message body of the notification
typestring (optional)The type of notification. This cannot be changed after creation. Available notification types:
- INFO
- WARNING
- SUCCESS

default is INFO
unreadboolean (optional)Determines if the message is read or unread

default is true
datenumber (optional)Date created in milliseconds elapsed since the UNIX epoch (January 1, 1970 00:00:00 UTC)

default is Date.now()
playSoundboolean (optional)Determines if a sound will play as the notification is pushed

default is true
lifeTimenumber (optional)Notification's life time in milliseconds. -1 for infinity.

default is 8000
showTimeboolean (optional)Whether time should be shown in the notification

default is false

Notification object

The Notification object represents the data structure of the response of the push method. It contains all attributes of the NotificationOptions object, with an addition of the id parameter.

PropertyTypeDescription
idnumberAn immutable, and unique identifier for this notification

notificationRead event

This event is emitted whenever a notification is read. Your callback will be called with an array of notification_ids read.

notificationRead((ids: number[]) => {})

Example

streamlabsOBS.v1.Notifications.notificationRead(ids => {
  console.log('Notifications Read', ids);
});

push method

push(NotificationOptions): Notification

This function is used to push a new notification.

Arguments

  1. NotificationsOptions object

Returns

Full Notification object returned.

Example

streamlabsOBS.v1.Notifications.push({
  message: "New Notification!"
}).then((notification: Notification) => {
	console.log("New notification", notification);
});

markAsRead method

markAsRead(id): void

This function is used to mark a notification as read.

Arguments

  1. id attribute of the Notifications object to be marked as read.

Returns

This method does not return anything.

Example

streamlabsOBS.v1.Notifications.markAsRead(1).then(() => {
	console.log("Marked as read");
});