Using Notifications

The Dolby Interactivity 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 not responsible for system notifications.

  • JavaScript
  • Swift
  • Java

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:

subscriptions_to_enable = [
  { type: "Conference.Created", conferenceAlias: "ExampleAlias" },
  { type: "Conference.Ended", conferenceAlias: "ExampleAlias" },
]
VoxeetSDK.notification
  .subscribe(subscriptions_to_enable)
  .then(() => console.log("subscription success"))

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"
  )
})

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

The subscription method takes an array of VTSubscribeBase objects:

subscribe(subscriptions: [VTSubscribeBase], completion: ((_ error: NSError?) -> Void)?)

The VTSubscribeBase objects are 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. Use the delegate accessor to receive future events:

class YourClass {
   init() {
      VoxeetSDK.shared.notification.delegate = self
   }
}

3. Call the subscribe method and include in it the proper subscription types:

let conferenceCreated = VTSubscribeConferenceCreated(conferenceAlias: "alias")
let conferenceEnded = VTSubscribeConferenceEnded(conferenceAlias: "alias")
let participantJoined = VTSubscribeParticipantJoined(conferenceAlias: "alias")
let participantLeft = VTSubscribeParticipantLeft(conferenceAlias: "alias")

VoxeetSDK.shared.notification.subscribe(subscriptions: [conferenceCreated, conferenceEnded, participantJoined, participantLeft], completion: { error in
    // check error
})

After this step, the application sends the notification request to the server to register the client for the specific notifications.

4. Use the delegate accessor to perform a specific action after receiving the notification. Mention all possible events, as in the following example:

VoxeetSDK.shared.notification.delegate = self

let conferenceCreated = VTSubscribeConferenceCreated(conferenceAlias: "alias")
VoxeetSDK.shared.notification.subscribe(subscriptions: [conferenceCreated], completion: { error in
    // check error
})

extension YourClass: VTNotificationDelegate {
    public func conferenceCreated(notification: VTConferenceCreatedNotification) {
        print("conference" + conferenceAlias + " has been created")
    }

    public func invitationReceived(notification: VTInvitationReceivedNotification) {}
    public func conferenceStatus(notification: VTConferenceStatusNotification) {}
    public func conferenceEnded(notification: VTConferenceEndedNotification) {}
    public func participantJoined(notification: VTParticipantJoinedNotification) {}
    public func participantLeft(notification: VTParticipantLeftNotification) {}
}

Note: Mention all listed events, otherwise the application will emit an error.

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

The subscription method takes an array of BaseSubscription objects:

subscribe(@NonNull subscriptions: List<BaseSubscription>): Promise

The BaseSubscription objects are implemented by the following subscription objects:

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

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 subscription type and the conference alias:

VoxeetSDK.notification().subscribe(subscriptions: SubscribeConferenceCreated, conferenceAlias: ExampleAlias)

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

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

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(@NonNull ConferenceCreatedNotificationEvent event) {
    Log.d(TAG, "ConferenceCreatedNotificationEvent: event:=" + event.conferenceId + " " + event.conferenceAlias);
    System.out.println("conference " + event.conferenceAlias + " has been created")
}

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

To configure notifications options on Android, check the following models: