User Content Message Formats
The Instant Messaging Service categorizes messages sent by users as User Content Messages. It provides predefined structures for text, images, GIFs, voice, files, short videos, locations, references, and combined forwarding.
Text Message
The Instant Messaging Service defines a text message with the ObjectName RC:TxtMsg.
- Built into the Client SDK, you can send it directly by calling relevant methods.
- When using the Server API, ensure the correct
ObjectNameand message content structure are passed:- Use
RC:TxtMsgin theObjectNamefield. - Pass the message content structure in the
contentfield.
- Use
Text Message Content Structure
The JSON object structure for a text message is as follows (serialize it into a JSON String for the content field):
{
\"content\":\"@张三 Hello world!\",
\"mentionedInfo\":{
\"type\":2,
\"userIdList\":[\"zhangsan\"],
\"mentionedContent\":\"有人@你\"
},
\"user\":
{
\"id\":\"4242\",
\"name\":\"Robin\",
\"portrait\":\"http://example.com/p1.png\",
\"extra\":\"extra\"
},
\"extra\":\"\"
}
| Name | Type | Required | Description |
|---|---|---|---|
| content | String | Yes | The text content, including emojis. |
| mentionedInfo | Object | No | Required for group @ messages. Not needed in one-on-one chats. When using the IM Server API, set isMentioned to 1 for @ messages. Otherwise, mentionedInfo is ignored. |
| mentionedInfo.type | int | Yes | @ type: 1 for @ all, 2 for specific users. |
| mentionedInfo.userIdList | String[] | No | List of specific users, valid when type is 2. |
| mentionedInfo.mentionedContent | String | No | Custom Push content for @ messages. Overrides default or custom pushContent. |
| user | String | No | Sender's user info. Not recommended unless in live streaming scenarios. |
| user.id | String | No | Sender's user ID. |
| user.name | String | No | Sender's nickname. |
| user.portrait | String | No | Sender's avatar. |
| user.extra | String | No | Extended info. |
| extra | String | No | Extended info. Can be removed. |
Client Default Properties
- Stored locally
- Counted in unread messages
- Supports offline push
- Push title: Defaults to sender's nickname for one-on-one and system messages, group name for group messages. Customizable when sending.
- Push content: Defaults to message content. For group messages, sender's nickname is prefixed. Customizable when sending.