React UI Kit: Add User Event Handler

Hi,

I am trying to follow the steps from this sendbird tutorial for adding a user event handler to the sdk

however, when I try to do something similar ; for instance, the following:

 useEffect(() => {
        if (sdk) {
            const userEventHandler: UserEventHandler = new UserEventHandler({
                onTotalUnreadMessageCountUpdated: (totalCount, countByCustomTypes) => {
                    console.log('onTotalUnreadMessageCountUpdated', totalCount, countByCustomTypes);
                },
            });
            sdk.addUserEventHandler('customEventTesting', userEventHandler);
        }
    }, [sdk]);

I’m getting the following error:

TypeError: sdk.addUserEventHandler is not a function

we are using the following npm packages:

"@sendbird/chat": "^4.2.3",
"@sendbird/uikit-react": "^3.3.3",

any ideas on how we can get this to work?

ultimately, we are trying to accomplish two things:

  1. get the count of unread messages
  2. send an email for each message sent

Thank you!

1 Like