/ SDKs / Flutter
SDKs
Chat SDKs Flutter v3
Chat SDKs Flutter
Chat SDKs
Flutter
Version 3
Sendbird Chat SDK v3 for Flutter is no longer supported as a new version is released. Check out our latest Chat SDK v4

Mention other users in a message

Copy link

In both group channels and open channels, a user can mention other users in a message to call their attention. Users have the option of calling specific users in the channel by their user IDs or calling all users in the channel.

Up to ten mentioned users are notified when mentioned. Notification preferences for mentions can be configured for each user in a channel.


Mention by user IDs

Copy link

To mention specific users when sending a message, add a list of user IDs to mentionedUserIds. Then, add the list to either UserMessageParams or FileMessageParams and pass the params to either sendUserMessage() or sendFileMessage(), respectively.

Mentioned users must belong to the channel where the message is being sent. Users who are mentioned but don't belong to the channel won't be included in the mentioned user IDs array of the sent message.

Note: Starting from Flutter Chat SDK 3.1.0, UserMessageParams requires the message parameter.

try {
    final userIDsToMention = ['Harry', 'Jay', 'Jin'];   // Only the mentioned users in the list will receive the message.
    final params = UserMessageParams(message: MESSAGE)
        ..mentionedUserIds = userIDsToMention;

    final preMessage = channel.sendUserMessage(params: params, onCompleted:(message, error) {
        // If error is null, the message is sent successfully. 
    });
} catch (e) {
    // Handle error.
}

Mention all channel users

Copy link

When a user types "@channel" or other designated text in a message, you can set mentionType to MentionType.channel and let the user call the attention of everyone in the channel.

try {
    final params = UserMessageParams(message: MESSAGE)
        ..mentionType = MentionType.channel

    final preMessage = channel.sendUserMessage(params, onCompleted: (msg, err) {
        // If error is null, the message is sent successfully.
    });
} catch (e) {
    // Handle error.
}

Limitations

Copy link

Using channel mention is subject to the following limitations.

Channel mentions per user

Copy link
Channel sizeAllowed mentions per hour

Less than or equal to 100 users

10

Greater than 100 users

1

Channel mentions per channel

Copy link
Channel sizeAllowed mentions per hour

Less than or equal to 100 users

100

Greater than 100 users

10