Message

Message

Message object, used to describe the properties of a message, including the message type, content, and conversation ID

Properties:
Name Type Default Description
ID String

Message ID

type String

Message type. Supported values are as follows:

Type Description
TIM.TYPES.MSG_TEXT Text message
TIM.TYPES.MSG_IMAGE Image message
TIM.TYPES.MSG_SOUND Audio message (Disused. Please use TIM.TYPES.MSG_AUDIO.)
TIM.TYPES.MSG_AUDIO Audio message
TIM.TYPES.MSG_VIDEO Video message
TIM.TYPES.MSG_FILE File message
TIM.TYPES.MSG_CUSTOM Custom message
TIM.TYPES.MSG_MERGER Combined message (supported from v2.10.1)
TIM.TYPES.MSG_GEO Location message
TIM.TYPES.MSG_GRP_TIP Group notification
TIM.TYPES.MSG_GRP_SYS_NOTICE Group system message
payload Object

Message content. Supported content types are as follows:

conversationID String

Conversation ID of the message

conversationType String

Conversation type of the message. Supported values are as follows:

Type Description
TIM.TYPES.CONV_C2C Client to Client (C2C) conversation
TIM.TYPES.CONV_GROUP Group conversation
TIM.TYPES.CONV_SYSTEM System conversation
to String

Recipient's userID

from String

Sender's userID. In the case of message sending, this field is set to the current login user by default.

flow String

Message flow

  • in: received message
  • out: sent message
time Number

Message timestamp, in seconds

status String

Message status

  • unSend: not sent
  • success: sent successfully
  • fail: sending failed
isRevoked Boolean false

Whether the message is a recalled message. true indicates that the message is a recalled message. (supported from v2.4.0)

priority String TIM.TYPES.MSG_PRIORITY_NORMAL

Message priority, used for group chat (supported from v2.4.2)

nick String

Nickname of the message sender (supported in AVChatRoom from v2.6.0; needs to be set by calling updateMyProfile in advance)

avatar String

Profile photo of the message sender (supported in AVChatRoom from v2.6.0; needs to be set by calling updateMyProfile in advance)

isPeerRead Boolean false

Whether a C2C message is read by the peer end. true indicates that the message is read by the peer end. (supported from v2.7.0)

nameCard String

Group name card of the message sender (supported from v2.9.0; can also be considered the group nickname of the message sender; needs to be set by calling setGroupMemberNameCard in advance)

atUserList Array

userIDs of @ group members in a group chat (supported from v2.9.0)

cloudCustomData String

Message custom data (saved in the cloud, will be sent to the peer end, and can still be pulled after the app is uninstalled and reinstalled; supported from v2.10.2)

isDeleted Boolean false

Whether the message is a deleted message. true indicates that the message is a deleted message (supported from v2.12.0)

isModified Boolean false

Whether the message is modified by a third party. true indicates that the message is modified by a third party. (supported from v2.12.1)

Methods

getRelayFlag() → {Boolean}

Whether to combine forward messages

Returns:

true -> Combine forward messages

Type
Boolean

setNameCard(nameCard)

Supplement the name card of the group message

Parameters:
Name Type Description
nameCard String

My group name card

Type Definitions

TextPayload

Properties:
Name Type Description
text String

Text message content

Payload structure of a text message

ImagePayload

Disused:
  • sizeType is disused from v2.8.0. Please use type instead.
Properties:
Name Type Description
uuid String

Unique identifier of an image

imageFormat Number

Image format type. JPG/JPEG = 1, GIF = 2, PNG = 3, BMP = 4, other = 255

imageInfoArray Array.<Object>

Image information

Properties
Name Type Description
width Number

Width

height Number

Height

url String

Image address, which can be used for rendering

size Number

Image size, in bytes

type Number
Value Description
0 Original image
1 198p compressed image
2 720p compressed image

Payload structure of an image message

AudioPayload

Properties:
Name Type Description
uuid String

Unique identifier

url String

Audio address, which can be used for playback

size Number

File size, in bytes

second Number

Audio duration, in seconds

Payload structure of an audio message

VideoPayload

Properties:
Name Type Description
videoFormat String

Video file format

videoSecond Number

Video file duration, in seconds and of integer type

videoSize Number

Video file size, in bytes

videoUrl String

Video file address, which can be used for playback

videoUUID String

Unique identifier of a video

thumbUUID String

Unique identifier of a thumbnail image

thumbSize Number

Thumbnail image size, in bytes

thumbWidth Number

Thumbnail image width

thumbHeight Number

Thumbnail image height

thumbUrl String

Thumbnail image address, which can be used for rendering

Payload structure of a video message

FilePayload

Properties:
Name Type Description
uuid String

Unique identifier

fileName String

File name

fileUrl String

File address

fileSize Number

File size, in bytes

Payload structure of a file message

CustomPayload

Properties:
Name Type Description
data String

"data" field of a custom message

description String

"description" field of a custom message

extension String

"extension" field of a custom message

Payload structure of a custom message

MergerPayload

Properties:
Name Type Description
downloadKey String

Key for downloading a combined message. If a combined message is large in size, the SDK will store it on the cloud, using this key as the unique identifier of the message.

messageList Array.<SimplifiedMessage>

List of messages combined

title String

Title of the combined message, for example, "Chat Records of the Talent Center in the Greater Bay Area"

abstractList String

Digest list. You can set digest information in different formats for different message types, for example: for a text message, the digest can be in the "sender:text" format. For an image message, the digest can be in the "sender:[image]" format. For a file message, the digest can be in the "sender:[file]" format.

compatibleText String

Compatible text. SDKs of early versions do not support combined messages, and they will send a text message with the content ${compatibleText} by default.

layersOverLimit Boolean

Whether the number of combination nesting levels exceeds the limit. true: the limit is exceeded, and the message is truncated. Default value: false

Payload structure of a combined message

GeoPayload

Properties:
Name Type Description
description String

Related description

latitude Number

Latitude

longitude Number

Longitude

Payload structure of a location message

GroupTipPayload

Properties:
Name Type Description
groupJoinType Number

Group joining type. Supported values are as follows:

Value Description
0 Default value, indicating that the operation is not a group joining operation
1 A user requests to join the group.
2 A user is invited to the group.
operatorID String

ID of the user who performs the operation

operationType Number

Operation type. Supported values are as follows:

Operation Type Value Description
TIM.TYPES.GRP_TIP_MBR_JOIN 1 A member joins the group.
TIM.TYPES.GRP_TIP_MBR_QUIT 2 A member leaves the group.
TIM.TYPES.GRP_TIP_MBR_KICKED_OUT 3 A group member is removed from the group.
TIM.TYPES.GRP_TIP_MBR_SET_ADMIN 4 A group member is granted the group admin role.
TIM.TYPES.GRP_TIP_MBR_CANCELED_ADMIN 5 The group admin role of a group member is revoked.
TIM.TYPES.GRP_TIP_GRP_PROFILE_UPDATED 6 The group profile is modified.
TIM.TYPES.GRP_TIP_MBR_PROFILE_UPDATED 7 The profile of a group member is modified. For example, a group member is muted.
userIDList Array.<String>

List of relevant userIDs

newGroupProfile Object

If a group profile is modified, this field stores the new group profile.

Properties
Name Type Description
groupCustomField Array.<Object>

If a group custom field is modified, this field stores the new custom field key-value pair. (Supported from v2.6.0)

memberList Array.<Object>

If a group member is muted, this field stores related information.

Properties
Name Type Description
userID String
muteTime Number

Muting duration, in seconds

Payload structure of a group notification. The system sends a group notification to all group members at an appropriate time. For example, when a user leaves or joins the group, the system sends the corresponding group notification to all group members.

GroupSystemNoticePayload

Properties:
Name Type Description
operatorID String

ID of the user who performs the operation

operationType Number

Operation type. Supported values are as follows:

Value Description Recipient
1 A user requests to join the group. Group admin and group owner
2 The request to join the group is approved. Requester
3 The request to join the group is rejected. Requester
4 A user is removed from the group. Removed user
5 The group is deleted. All group members
6 The group is created. Creator
7 A user is invited to the group. Invitee
8 A user leaves the group. User who leaves the group
9 The admin is modified. New admin
10 The admin is canceled. Canceled admin
11 The group is repossessed. All members (not displayed)
12 A user received a group joining invitation, and needs to accept or reject the invitation. Invitee
13 A user invites others to join the group, and the invitation is accepted. Inviter
14 A user invites others to join the group, and the invitation is rejected. Inviter
15 Read report synchronized across multiple terminals. Reporter
255 A custom notification is triggered. All members by default
groupProfile Object

Profile of the relevant group

userDefinedField String

User-defined field. When sending a custom notification via RESTful APIs, you can get the content of the custom notification in the value of this property.

handleMessage Object

Remarks on the processing. For example, if user1 enters remarks on an application to join group1 that requires approval, the admin of group1 will see this field in the group system message.

Payload structure of a group system message. The system sends a group system message to all group members at an appropriate time. For example, when user1 is deleted from a group, the system sends the corresponding group system message to user1.