Chat / iOS
Chat iOS v4
Chat iOS
Chat
iOS
Home
/
Chat
/
iOS
/
Message
This is the new Docs for Chat SDK v4 for iOS. To see the previous Docs, click here.

Mention other users in a message

In both group channels and open channels, a user can mention other users in a message to call their attention. The following steps explain how to mention other users in a message.

  1. Specify a list of user IDs to mention.

  2. Add the list to either UserMessageCreateParams or FileMessageCreateParams which may contain options for further action.

  3. Pass the params to either sendUserMessage(params:completionHandler:) or sendFileMessage(params:completionHandler:).

  4. Up to ten users mentioned in the message will be notified.

var userIdsToMention: [String] = []
userIdsToMention.append("Harry")
userIdsToMention.append("Jay")
userIdsToMention.append("Jin")

let params = UserMessageCreateParams(message: MESSAGE)
params.mentionedUserIds = userIdsToMention
params.mentionType = .users

channel.sendUserMessage(params: params) { userMessage, error in
    guard error == nil else {
        // Handle error.
        return
    }
}