Mention
Mention is a feature that allows users to call out each other in a message within a group channel. Users can mention other members in the group channel to get their attention and directly notify that they've been mentioned in a message.
Limitations
The mention feature currently has the following limitations:
- Mention is available for group channels only.
- User is the only mention type that Sendbird UIKit provides.
- Users can only mention other users in the same channel.
- Users can have up to 10 mentions in a single message.
How to use
To turn on the feature, refer to the code below:
Configure mention settings
The mention feature has basic settings that you can customize when implementing it in your client app. Once isUserMentionEnabled
is set to true
, a new SBUUserMentionConfiguration
instance is created. userMentionConfig
, a property in the SBUGlobals
class, must be set to the SBUUserMentionConfiguration
instance in order to use the feature. The following customizable properties of SBUUserMentionConfiguration
should also be configured prior to mentioning users in a channel.
SBUUserMentionConfiguration
Property | Type | Description |
---|---|---|
mentionLimit | Int | Specifies the maximum number of times users can mention another user in a single message. (Default: |
suggestionLimit | Int | Specifies the maximum number of users shown in a suggested mention list. (Default: |
The maximum number of times you can mention the same user or multiple users in one message is 10. The maximum number of users shown in a suggested mention list is set to 15 by default. These numbers are customizable through userMentionConfig
, which contains mentionLimit
and suggestionLimit
properties.
Mention a user
Users can mention other users in the same channel by either searching for the channel member or typing in the user's nickname. When a user types @
in the inputComponent of SBUGroupChannelViewController
, a suggested mention list appears in the listComponent of the group channel view. The SBUSuggestedMentionList
class contains a scrollable list of suggested channel members by their nickname or user ID. The list also appears while the user types the nickname of a channel member. As the nickname is being typed, the list sorts the nicknames in an alphabetical order in real-time.
Suggested mention list
The suggested mention list shows an alphabetical list of all channel members that you can mention in a message. For each member in the list, the profile image, nickname, and user ID are shown by default. You can choose to display either just the nickname or both nickname and user ID. The suggested mention list disappears once a user has been successfully mentioned in a message or when there's no matching nickname found in the list. If there's a typo while typing in a user's nickname or if the user's not a member of the current group channel, the mention list also disappears.
If a user reaches the value of mentionLimit
, a warning guide appears in the suggested mention list view. To show the guide, the isLimitGuideEnabled
property of SBUSuggestedMentionList
must be set to true
. Then the customizable limitGuideCell
of the guide is displayed in the suggested mention list view.
Customize the UI of limit guide
The following tables show customizable properties and method used to modify the UI of the limit guide in the suggested mention list view.
SBUSuggestedMentionList
Property name | Type | Description |
---|---|---|
limitGuideCell | UITableViewCell | Specifies the UI displaying the limit guide cell in the suggested mention list view. |
Method | Type | Description |
---|---|---|
isLimitGuideEnabled | Bool | Determines whether to turn on the guide that appears when a user reaches the set value of |
SBUMentionLimitGuideCell
Property name | Type | Description |
---|---|---|
limitGuideLabel | UILabel | Specifies the |
Mention input
When you type @
and a user nickname in the inputComponent of SBUGroupChannelViewController
, the suggested mention list appears. While the list can display both nickname and user ID, you can only type nicknames in the message input field to mention a user. The same user can be mentioned up to 10 times per message by default and the text of each user mention is bolded.
Theme
To display the suggested mention list view, SBUSuggestedMentionList
uses SBUChannelTheme
and SBUUserCellTheme
. The following table shows customizable theme properties of SBUChannelTheme
and SBUUserCellTheme
.
SBUChannelTheme
Category | Property | Description |
---|---|---|
Channel | mentionLimitGuideTextFont | The text font of the limit guide. (Default: |
Channel | mentionLimitGuideTextColor | The text color of the limit guide. (Default: |
Channel | separatorColor | The color of the line that separates the suggested mention list from the listComponent. (Default: |
SBUUserCellTheme
Category | Property | Description |
---|---|---|
User cell | nicknameTextFont | The text font of the user nickname in the suggested mention list. (Default: |
User cell | nicknameTextColor | The text color of the user nickname in the suggested mention list. (Default: |
User cell | nonameTextColor | The text color of a mentioned user who doesn't have a nickname. (Default: |
User cell | userIdTextFont | The text font of the user's user ID in the suggested mention list. (Default: |
User cell | userIdTextColor | The text color of the user's user ID in the suggested mention list. (Default: |
The SBUMessageInputView
class uses SBUMessageInputTheme
to customize the UI of the user mentions in the message input field. The following table shows theme properties of SBUMessageInputTheme
.
SBUMessageInputTheme
Category | Property | Description |
---|---|---|
Message input | mentionTextFont | The text font of the mentioned user. (Default: |
Message input | mentionTextColor | The text color of the mentioned user. (Default: |
Message input | mentionTextBackgroundColor | The background color of the mentioned user. (Default: |
Customize SBUStringSet
The following table shows a customizable property of SBUStringSet
that appears in the suggested mention list view. The SBUStringSet
class is a set of strings used to compose a view. You need to modify the stringSet
values in advance if you wish to make changes to the view.
Property name | Description |
---|---|
Mention.Limit_Guide | A text in the |
Customize SBUIconSet
The following table shows a customizable icon in the suggested mention list view.
Icon | Image | Description |
---|---|---|
iconInfo | An icon used to indicate that the user has reached the maximum mention count in a single message. |
Receive a mention
When a user is mentioned in a message, the unread message count in the listComponent of SBUGroupChannelListViewController
increases by the number of unread mentioned messages. A mention badge also appears to the left of the unread message count number to indicate that the user has been mentioned in one of the unread messages. Regardless of the number of unread mentioned messages, if there's at least one unread mentioned message in the channel, the mention badge appears in the channel list.
When the most recently sent message in a channel mentions the current user, the unread mentioned message is displayed in the channel list view through the unreadMentionLabel
property of SBUGroupChannelCell
.
Once the user taps on the channel with the unread mentioned message, they can see all the messages in the listComponent of SBUGroupChannelViewController
where the highlighted user's nickname appears. The nickname is highlighted only in messages that mention the current user.
Customize the UI of unread mentioned message
The following table shows a customizable property used to modify the UI of the unread mentioned message in a channel list view.
SBUGroupChannelCell
Property name | Type | Description |
---|---|---|
unreadMentionLabel | UILabel | Specifies the |
User profile
Users can tap on each mentioned nickname in a message to see the user profile of the mentioned channel member. The user profile includes a profile image, nickname, and user ID.
Theme
To display the unread mentioned message in a channel cell, the channel list view uses SBUChannelCellTheme
. The following table shows customizable theme properties of SBUChannelCellTheme
.
SBUChannelCellTheme
Category | Property | Description |
---|---|---|
Channel cell | unreadMentionTextFont | The text font of the unread mentioned message. (Default: |
Channel cell | unreadMentionTextColor | The text color of the unread mentioned message. (Default: |
To display the user mention in a message cell, the group channel view uses SBUMessageCellTheme
. The following table shows customizable theme properties of SBUMessageCellTheme
.
SBUMessageCellTheme
Category | Property | Description |
---|---|---|
Message cell | mentionTextFont | The text font of the user mention. (Default: |
Message cell | mentionLeftTextColor | The text color of the user mention in messages sent by other channel members. (Default: |
Message cell | mentionRightTextColor | The text color of the user mention in messages sent by the current user. (Default: |
Message cell | mentionLeftTextBackgroundColor | The background color of the user mention in messages sent by other channel members. (Default: |
Message cell | mentionRightTextBackgroundColor | The background color of the user mention in messages sent by the current user. (Default: |
Push notifications for mentions
The option to turn on notifications for mentions only has been added to the listComponent of SBUGroupChannelSettingsViewController
. If you turn on push notifications for the channel using the toggle button, two options will appear below: all new messages and mentions only. All new messages include notifications for both non-mentioned messages and mentioned messages, whereas mentions only refer to notifications for just mentioned messages.
Customize SBUStringSet
The following table shows a customizable property of SBUStringSet
that appears in the notification settings menu. The SBUStringSet
class is a set of strings used to compose a view. You need to modify the stringSet
values in advance if you wish to make changes to the view.
Property name | Description |
---|---|
ChannelSettings_Notifications_Mentions_Only | A text indicating the current notification settings for the channel. The string is set to |
ChannelPushSettings_Notification_Title | A text indicating that the toggle button refers to push notifications. The string is set to |
ChannelPushSettings_Notification_Description | A text indicating that turning on the toggle button allows the user to to be notified when messages are delivered to the channel. The string is set to |
ChannelPushSettings_Item_All | A text indicating that if this radio button is selected, the user will receive notifications for all messages sent to the channel. The string is set to |
ChannelPushSettings_Item_Mentions_Only | A text indicating that if this radio button is selected, the user will receive notifications for mentions only. The string is set to |
Customize SBUIconSet
The following table shows a customizable icon in the notification settings menu.
Icon | Image | Description |
---|---|---|
iconRadioButtonOn | An icon used to indicate that either | |
iconRadioButtonOff | An icon used to indicate that either |