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

Add or remove a user event handler

To receive information about events related to users connected to the Sendbird server, add a user event handler with its unique user-defined ID by calling SendbirdChat.addUserEventHandler().

If you want to stay informed of changes related to users and notify users' client apps of these changes, define and register multiple user event handlers to each Activity instance.


User event types

List of user events

To add or remove onTotalUnreadMessageCountChanged(), visit this page and contact us on the Sendbird Dashboard.

MethodInvoked whenNotified devices

onTotalUnreadMessageCountChanged()

A user has read messages in the joined group channels and there is an update on the total number of the user's unread messages.

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


Add a user event handler

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

SendbirdChat.addUserEventHandler(
    UNIQUE_HANDLER_ID,
    object : UserEventHandler() {
        override fun onTotalUnreadMessageCountChanged(totalCount: Int, totalCountByCustomType: Map<String, Int>) {}
    }
)

Remove a user event handler

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

SendbirdChat.removeUserEventHandler(UNIQUE_HANDLER_ID);