Using Notifications

The Dolby.io Communications APIs offer the notification service which allows application users to receive notifications related to conference events, even when users have not yet joined the conference.

The notification service consists of two parts: subscribing to notifications from the server and using event listeners. The subscription informs the server that the client wishes to receive the events. The event listeners allow developers to register callbacks and perform a specific programming action.

The notification service is responsible for notifying application users about the received conference invitations, created and ended conferences, and participants who joined or left conferences. The notification service is not responsible for any other notifications.

JavaScript

The subscription method takes an array of BaseSubscription objects:

subscribe(subscriptions: Array‹BaseSubscription›): any

The BaseSubscription object is implemented by the following subscription objects:

Note: By default, the subscription to invitations is enabled for all application users.

Note: Dolby.io service terminates conferences after the established time if no one joins the new conference or the last participant leaves it. Use the ttl parameter to customize the waiting time and terminate empty conferences.

To unsubscribe from notifications, use the unsubscribe method, similarly to using the subscribe method.

To properly use notifications, follow this workflow:

1. Initialize the SDK and open a session. This step opens a WebSocket responsible for sending notification messages from the server to the client.

2. Call the subscribe method using the proper SubscriptionType and conference alias:

const subscriptions_to_enable = [
  { type: "Conference.Created", conferenceAlias: "ExampleAlias" },
  { type: "Conference.Ended", conferenceAlias: "ExampleAlias" },
];
await VoxeetSDK.notification.subscribe(subscriptions_to_enable);

After this step, the application sends the notification request to the server to register the client for the specific notifications. The application emits the conferenceStatus event to inform the user about the status of the subscribed conference.

3. Use an event listener to perform a specific action after receiving the notification:

VoxeetSDK.notification.on("conferenceCreated", (confCreatedNotification) => {
  console.log(`Conference ${confCreatedNotification.conferenceAlias} has been created.`);
});

VoxeetSDK.notification.on("conferenceEnded", (confCreatedNotification) => {
  console.log(`Conference ${confCreatedNotification.conferenceAlias} has ended.`);
});

After receiving the notification from the server, the application triggers the requested action.