Quick Reference for AI Agents & Developers
- Mention format:
<@uid:USER_UID>in message text (e.g.,"Hello <@uid:cometchat-uid-1>") - Get mentioned users:
message.mentionedUsersreturns array of mentionedUserobjects - Check if mentioned:
message.mentionedMereturnsBool - Fetch with tag info:
MessagesRequest.MessageRequestBuilder().mentionsWithTagInfo(true).build() - Related: Send Message · Receive Message · Messaging Overview
Mention Format
Example message text with mention:
Send Mentioned Messages
Every User object has a String unique identifier associated with them which can be found in a property calleduid. To mention a user in a message, the message text should contain the uid in following format: <@uid:UID_OF_THE_USER>.
- Swift (User)
- Swift (Group)
Sample Payloads - Send Mentioned Message (User)
Sample Payloads - Send Mentioned Message (User)
- Request
- Success Response
Method:
CometChat.sendTextMessage(message:)Sample Payloads - Send Mentioned Message (Group)
Sample Payloads - Send Mentioned Message (Group)
- Request
- Success Response
Method:
CometChat.sendTextMessage(message:)You can mention users in text messages and media message captions.
Fetch Mentioned Messages
By default, the SDK will fetch all messages irrespective of whether the logged-in user is mentioned or not. The SDK allows you to fetch messages with additional mention information.Mentions With Tag Info
- Swift (User)
- Swift (Group)
Sample Payloads - Fetch Mentions with Tag Info
Sample Payloads - Fetch Mentions with Tag Info
- Request
- Success Response
Method:
MessagesRequest.fetchPrevious()Mentions With Blocked Info
- Swift (User)
Sample Payloads - Fetch Mentions with Blocked Info
Sample Payloads - Fetch Mentions with Blocked Info
- Request
- Success Response
Method:
MessagesRequest.fetchPrevious()Get Users Mentioned In a Message
To retrieve the list of users mentioned in a particular message:- Swift
Check if Logged-in User Was Mentioned
To check if the logged-in user has been mentioned in a particular message:- Swift