/ SDKs / JavaScript
Chat SDKs JavaScript v4
Chat SDKs JavaScript
Chat SDKs
Version 4

Add or remove a user event handler

Copy link

To receive information about events related to users connected to the Sendbird server, add a user event handler with its UNIQUE_HANDLER_ID by calling sb.addUserEventHandler().

If you want to stay informed of changes related to users and notify the changes to different client apps, define and register multiple channel event handlers using the UNIQUE_HANDLER_ID.

User event types

Copy link

List of user events

Copy link
MethodInvoked whenNotified devices


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 and the number of unread messages by custom channel type.

Add a user event handler

Copy link

The following code shows the supported event callback with its parameters and how to add a user event handler to the unique SendbirdChat instance.

Note: The countByCustomTypes attribute is turned off by default. Contact us if you wish to use this feature.

const userEventHandler = new UserEventHandler({
  onTotalUnreadMessageCountChanged: (unreadMessageCount) => {},

sb.addUserEventHandler(UNIQUE_HANDLER_ID, userEventHandler);

Remove a user event handler

Copy link

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