new Message()
消息对象,用于描述一条消息具有的属性,如类型、消息的内容、所属的会话 ID 等。
Properties:
Name | Type | Default | Description | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ID |
String |
消息 ID |
|||||||||||||||||||||||
type |
String |
消息类型,具体如下:
|
|||||||||||||||||||||||
payload |
Object |
消息的内容,具体如下: |
|||||||||||||||||||||||
conversationID |
String |
消息所属的会话 ID |
|||||||||||||||||||||||
conversationType |
String |
消息所属会话的类型,具体如下:
|
|||||||||||||||||||||||
to |
String |
接收方的 userID |
|||||||||||||||||||||||
from |
String |
发送方的 userID,在消息发送时,会默认设置为当前登录的用户 |
|||||||||||||||||||||||
flow |
String |
消息的流向
|
|||||||||||||||||||||||
time |
Number |
消息时间戳。单位:秒 |
|||||||||||||||||||||||
status |
String |
消息状态。
|
|||||||||||||||||||||||
isRevoked |
Boolean |
false
|
是否被撤回的消息,true 标识被撤回的消息(v2.4.0起支持) |
||||||||||||||||||||||
priority |
String |
TIM.TYPES.MSG_PRIORITY_NORMAL
|
消息优先级,用于群聊(v2.4.2起支持) |
||||||||||||||||||||||
nick |
String |
消息发送者的昵称(v2.6.0起,在 AVChatRoom 内支持,需提前调用 updateMyProfile 设置) |
|||||||||||||||||||||||
avatar |
String |
消息发送者的头像地址(v2.6.0起,在 AVChatRoom 内支持,需提前调用 updateMyProfile 设置) |
|||||||||||||||||||||||
isPeerRead |
Boolean |
false
|
C2C 消息对端是否已读,true 标识对端已读(v2.7.0起支持) |
||||||||||||||||||||||
nameCard |
String |
消息发送者的群名片(v2.9.0起支持,也可称之为消息发送者的群昵称),需提前调用 setGroupMemberNameCard 设置 |
|||||||||||||||||||||||
atUserList |
Array |
群聊时此字段存储被 at 的群成员的 userID(v2.9.0起支持) |
Type Definitions
TextPayload
Properties:
Name | Type | Description |
---|---|---|
text |
String |
文本消息内容 |
文本消息的 payload 结构
ImagePayload
- Deprecated:
-
- sizeType v2.8.0起废弃,请使用 type 代替
Properties:
Name | Type | Description | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
uuid |
String |
图片唯一标识 |
||||||||||||||||||||||||||
imageFormat |
Number |
图片格式类型,JPG/JPEG = 1,GIF = 2,PNG = 3,BMP = 4,其他 = 255 |
||||||||||||||||||||||||||
imageInfoArray |
Array.<Object> |
图片信息 Properties
|
图片消息的 payload 结构
AudioPayload
Properties:
Name | Type | Description |
---|---|---|
uuid |
String |
唯一标识 |
url |
String |
音频地址,可用于播放 |
size |
Number |
文件大小,单位:Byte |
second |
Number |
音频时长,单位:秒 |
音频消息的 payload 结构
VideoPayload
Properties:
Name | Type | Description |
---|---|---|
videoFormat |
String |
视频文件的格式 |
videoSecond |
Number |
视频文件的时长,单位秒,整型 |
videoSize |
Number |
视频文件大小,单位:Byte |
videoUrl |
String |
视频文件的地址,可用于播放 |
videoUUID |
String |
video 唯一标识 |
thumbUUID |
String |
thumb 唯一标识 |
thumbSize |
Number |
缩略图大小,单位:Byte |
thumbWidth |
Number |
缩略图宽度 |
thumbHeight |
Number |
缩略图高度 |
thumbUrl |
String |
缩略图地址,可用于渲染 |
视频消息的 payload 结构
FilePayload
Properties:
Name | Type | Description |
---|---|---|
uuid |
String |
唯一标识 |
fileName |
String |
文件名 |
fileUrl |
String |
文件地址 |
fileSize |
Number |
文件大小,单位:Byte |
文件消息的 payload 结构
CustomPayload
Properties:
Name | Type | Description |
---|---|---|
data |
String |
自定义消息的 data 字段 |
description |
String |
自定义消息的 description 字段 |
extension |
String |
自定义消息的 extension 字段 |
自定义消息的 payload 结构
GeoPayload
Properties:
Name | Type | Description |
---|---|---|
description |
String |
相关描述信息 |
latitude |
Number |
纬度 |
longitude |
Number |
经度 |
位置消息的 payload 结构
GroupTipPayload
Properties:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
groupJoinType |
Number |
加群类型,具体如下:
|
||||||||||||||||||||||||
operatorID |
String |
执行该操作的用户 ID |
||||||||||||||||||||||||
operationType |
Number |
操作类型,具体如下:
|
||||||||||||||||||||||||
userIDList |
Array.<String> |
相关的 userID 列表 |
||||||||||||||||||||||||
newGroupProfile |
Object |
若是群资料变更,该字段存放变更的群资料 Properties
|
||||||||||||||||||||||||
memberList |
Array.<Object> |
当群成员被禁言时,可在该字段中拿到相关信息 Properties
|
群提示消息的 payload 结构。系统会在恰当的时机,向全体群成员发出群提示消息。例如:有群成员退群/进群,系统会给所有群成员发对应的群提示消息。
GroupSystemNoticePayload
Properties:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
operatorID |
String |
执行该操作的用户 ID |
||||||||||||||||||||||||||||||||||||
operationType |
Number |
操作类型,具体如下:
|
||||||||||||||||||||||||||||||||||||
groupProfile |
Object |
相关的群组资料 |
||||||||||||||||||||||||||||||||||||
userDefinedField |
String |
用户自定义字段。使用 RestAPI 发送自定义通知时,可在该属性值中拿到自定义通知的内容。 |
||||||||||||||||||||||||||||||||||||
handleMessage |
Object |
处理的附言。例如:user1 申请加入 group1 时,若进群需要验证,且 user1 填写了申请加群的附言。则 group1 的管理员会在相应群系统通知中看到该字段。 |
群系统通知的 payload 结构。系统会在恰当的时机,向特定用户发出群系统通知。例如:user1 被踢出群组,系统会给 user1 发送对应的群系统消息。