Chat / iOS
Chat iOS v4
Chat iOS
Chat
iOS
Home
/
Chat
/
iOS
/
Event delegate
This is the new Docs for Chat SDK v4 for iOS. To see the previous Docs, click here.

Add or remove a user event delegate

To receive information about events related to users connected to the Sendbird server, add a user event delegate UserEventDelegate) with its unique user-defined ID.

If you want to stay informed of changes related to users and notify the changes to different client apps, define and register multiple user event delegates to each view controller.


User event types

List of user events

MethodInvoked whenNotified devices

didUpdateTotalUnreadMessageCount(_:totalCountByCustomType:)

There has been an update on the total number of a user's unread messages because the user read messages in group channels.

The user's devices running client apps. The devices are notified with the total number of unread messages along with a collection of the number of unread messages by custom channel type.


Add a user event delegate

The following code shows a full set of supported event callbacks with their parameters and how to add a user event delegate to the unique SendbirdChat instance.

Note: To retrieve totalCountByCustomType, visit this page and contact us on Sendbird Dashboard.

// CustomViewController.swift
class CustomViewController: UIViewController, UserEventDelegate {
    func initViewController() {
        SendbirdChat.add(self as UserEventDelegate, identifier: UNIQUE_DELEGATE_ID)
    }

    func didUpdateTotalUnreadMessageCount(_ totalCount: Int32, totalCountByCustomType: [String : NSNumber]?) {

    }
}

Remove a user event delegate

The following code shows how to remove the user event delegate.

SendbirdChat.removeUserEventDelegate(forIdentifier: UNIQUE_DELEGATE_ID)