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
object
The NotificationOptions
object represents the data structure of a new notification to be pushed.
Property | Type | Description |
---|---|---|
message | string | The message body of the notification |
type | string (optional) | The type of notification. This cannot be changed after creation. Available notification types: - INFO - WARNING - SUCCESS default is INFO |
unread | boolean (optional) | Determines if the message is read or unread default is true |
date | number (optional) | Date created in milliseconds elapsed since the UNIX epoch (January 1, 1970 00:00:00 UTC) default is Date.now() |
playSound | boolean (optional) | Determines if a sound will play as the notification is pushed default is true |
lifeTime | number (optional) | Notification's life time in milliseconds. -1 for infinity. default is 8000 |
showTime | boolean (optional) | Whether time should be shown in the notification default is false |
Notification object
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.
Property | Type | Description |
---|---|---|
id | number | An immutable, and unique identifier for this notification |
notificationRead event
event
This event is emitted whenever a notification is read. Your callback will be called with an array of notification_id
s read.
notificationRead((ids: number[]) => {})
Example
streamlabsOBS.v1.Notifications.notificationRead(ids => {
console.log('Notifications Read', ids);
});
push method
method
push(NotificationOptions): Notification
This function is used to push a new notification.
Arguments
- 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
method
markAsRead(id): void
This function is used to mark a notification as read.
Arguments
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");
});
Updated about 6 years ago