NEWDolby Interactivity APIs are now the Dolby.io Communications APIs Learn More >
X

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.

iOS

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.


Did this page help you?