类型: class
IM 类,所有 API 交互都通过该类的实例来操作,实例化支持的参数参见 IMOption。
| 方法 | 描述 |
|---|---|
| init | 初始化 SDK。 初始化时会完成与服务端的消息游标同步和历史信息同步。 |
| getMessagesByUser | 拉取用户混链消息。 通常无需业务调用,SDK 内部会轮询。 |
| createCustomMessage | 创建自定义消息。 |
| createTextMessage | 创建文本消息。 |
| sendMessage | 发送消息。 目前仅支持直接发送普通文本消息,发送图片消息、视频消息、语音消息、文件消息前请联系技术支持同学进行配置。 |
| deleteMessage | 删除消息。 |
| recallMessage | 撤回消息。 |
| getMessageByServerId | 获取消息的实时信息。 |
| getMessageReferenceList | 获取引用消息链。 若消息 B 引用了消息 A,消息 C 引用了消息 B,那么 A -> B -> C 就是一条引用消息链。通过 A、B、C 任意一条消息都可以获取这条消息链。 |
| modifyMessageProperty | 设置消息属性,常见使用场景:给某条消息点赞、加急等。(直播群暂不支持) |
| getConversation | 获取指定单个本地会话。 |
| getConversationOnline | 请求服务端更新本地会话后,获取指定单个会话。 |
| getConversationList | 获取本地会话列表。 |
| getConversationListOnline | 请求服务端更新本地会话后,获取会话列表。直播群列表请使用 getLiveConversationListOnline。 |
| getMessagesByConversation | 从服务器获取会话内区间的消息,默认情况下从本地最早的消息开始拉取 (cursor = conversation.firstMessageIndex) (直播群不可用) |
| getUserConversationList | 请求服务器获取用户的会话列表。 |
| createConversation | 创建群聊。 |
| leaveConversation | 离开群组。 |
| deleteConversation | 删除会话。 |
| dissolveConversation | 解散群聊。 |
| setConversationSettingInfo | 设置会话附加信息,如置顶、免打扰、收藏等。 |
| setConversationWeakMuteConfig | 配置会话低打扰模式。 |
| upsertConversationSettingExtInfo | 更新 Setting ext 拓展信息。 |
| setConversationCoreInfo | 设置群聊信息。 |
| upsertConversationCoreExtInfo | 更新 Core ext 拓展信息。 |
| getConversationListByTop | 获取顶置会话。 |
| getConversationListByFavorite | 获取收藏会话。 |
| markConversationRead | 标记会话已读。 |
| addParticipants | 添加群成员。 |
| removeParticipants | 移除群成员/离开直播群/移除直播群成员,v1.1.0 新增直播群功能。 |
| updateParticipant | 更新群成员信息。 |
| getParticipants | 获取 SDK 本地维护的群成员列表。 |
| getParticipantsOnline | 获取群成员列表。 此方法会在 SDK 内部循环调用分页接口,直至没有更多数据,然后把所有群成员数据一次返回。当群成员较多时,此方法耗时较久。 |
| setConversationMute | 设置群禁言(会话维度)。 |
| setParticipantMuteTime | 设置群禁言(成员维度)。 |
| dispose | 手动卸载 SDK。 |
初始化 SDK。
初始化时会完成与服务端的消息游标同步和历史信息同步。
类型
(params?: { convLimit?: number; msgLimit?: number; convTotal?: number;}) => Promise<InitResult>
ts注意
可设置 IMOption.disableInitPull 关闭历史信息同步。
参数
params
类型: { convLimit?: number | undefined; msgLimit?: number | undefined; convTotal?: number | undefined; } | undefined
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| convLimit | number | undefined | 每次调用初始化拉取接口时,会话数量限制。 |
| msgLimit | number | undefined | 每次调用初始化拉取接口时,每个对话返回的消息数量限制。 |
| convTotal | number | undefined | 初始化拉取的会话总数量限制。该值非 0 时,当本地会话数量大于等于该值时停止拉取。 |
返回值
类型: Promise<InitResult>
初始化结果。
拉取用户混链消息。
通常无需业务调用,SDK 内部会轮询。
类型
(params?: { cursor?: Long | string | number | Date; limit?: number; inboxType?: number;}) => Promise<void>
ts参数
params
类型: { cursor?: string | number | Date | Long | undefined; limit?: number | undefined; inboxType?: number | undefined; }
默认值: ' {}'
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| cursor | string | number | Date | Long | undefined | 拉取消息位置游标。 |
| limit | number | undefined | 单次拉取消息数量。 |
| inboxType | number | undefined | 信箱类型。 |
创建自定义消息。
类型
(params: { conversation: Conversation; content: string; clientId?: string | undefined; ext?: { [k: string]: string; } | undefined; mentionedUsers?: string[] | undefined; insert?: boolean | undefined; referenceMessage?: Message | undefined; referenceHint?: string | undefined; }) => Promise<Message>
ts参数
params
类型: { conversation: Conversation; content: string; clientId?: string | undefined; ext?: { [k: string]: string; } | undefined; mentionedUsers?: string[] | undefined; insert?: boolean | undefined; referenceMessage?: Message | undefined; referenceHint?: string | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 当前发送消息的会话。 |
| content | string | 消息体。 |
| clientId | string | undefined | 客户端 ID。 |
| ext | { [k: string]: string; } | undefined | 消息拓展属性。 |
| mentionedUsers | string[] | undefined | 需要 @ 的用户列表。 |
| insert | boolean | undefined | 消息创建后是否 process 处理(新消息处理流程)。 |
| referenceMessage | Message | undefined | 引用的消息。 |
| referenceHint | string | undefined | 业务透传的引用信息,传入自定义引用线索。 |
返回值
创建的消息,参看 Message。
创建文本消息。
类型
(params: { conversation: Conversation; content: string; clientId?: string | undefined; ext?: { [k: string]: string; } | undefined; mentionedUsers?: string[] | undefined; insert?: boolean | undefined; referenceMessage?: Message | undefined; referenceHint?: string | undefined; }) => Promise<Message>
ts参数
params
类型: { conversation: Conversation; content: string; clientId?: string | undefined; ext?: { [k: string]: string; } | undefined; mentionedUsers?: string[] | undefined; insert?: boolean | undefined; referenceMessage?: Message | undefined; referenceHint?: string | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 当前发送消息的会话。 |
| content | string | 消息体。 |
| clientId | string | undefined | 客户端 ID。 |
| ext | { [k: string]: string; } | undefined | 消息拓展属性。 |
| mentionedUsers | string[] | undefined | 需要 @ 的用户列表。 |
| insert | boolean | undefined | 消息创建后是否 process 处理(新消息处理流程)。 |
| referenceMessage | Message | undefined | 引用的消息。 |
| referenceHint | string | undefined | 业务透传的引用信息,传入自定义引用线索。 |
返回值
创建的消息,参看 Message。
发送消息。
目前仅支持直接发送普通文本消息,发送图片消息、视频消息、语音消息、文件消息前请联系技术支持同学进行配置。
类型
(params: { message: Message; priority?: im_proto.MessagePriority;}) => Promise<SendMessageResult>
ts参数
params
类型: { message: Message; priority?: im_proto.MessagePriority | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| message | Message | 要发送的消息,由 createXxxMessage 接口创建。 |
| priority | im_proto.MessagePriority | undefined | 消息的优先级(适用于直播群消息) |
返回值
发送消息结果。
删除消息。
类型
(params: { message: Message; localOnly?: boolean;}) => Promise<void>
ts参数
params
类型: { message: Message; localOnly?: boolean | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| message | Message | 待删除的消息。 |
| localOnly | boolean | undefined | 是否仅删除本地,不同步到服务端。 |
撤回消息。
类型
(params: { message: Message;}) => Promise<void>
ts参数
params
类型: { message: Message; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| message | Message | 待撤回的消息。 |
获取消息的实时信息。
类型
(params: { conversation: Conversation; serverMessageId: string;}) => Promise<Message | null>
ts参数
params
类型: { conversation: Conversation; serverMessageId: string; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 会话信息。 |
| serverMessageId | string | 消息的 serverId。 |
返回值
参看 Message。
获取引用消息链。
若消息 B 引用了消息 A,消息 C 引用了消息 B,那么 A -> B -> C 就是一条引用消息链。通过 A、B、C 任意一条消息都可以获取这条消息链。
类型
(params: { message: Message;}) => Promise<Message[]>
ts参数
params
类型: { message: Message; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| message | Message | 消息体。 |
返回值
类型: Promise<Message[]>
引用消息链。
设置消息属性,常见使用场景:给某条消息点赞、加急等。(直播群暂不支持)
类型
(params: { message: Message; modifyContent: Array<{ key: string; operation?: im_proto.OPERATION_TYPE; value?: string; idempotentId?: string; }>;}) => Promise<ModifyMessagePropertyResult>
ts注意
消息加急本质上是修改消息属性,在中台侧仅为一个状态变更。加急之后的附加操作(如全局提醒、短信电话提醒等)需要业务方自行处理。
参数
params
类型: { message: Message; modifyContent: Array<{ key: string; operation?: im_proto.OPERATION_TYPE; value?: string; idempotentId?: string;}>; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| message | Message | 消息体。 |
| modifyContent | { key: string; operation?: im_proto.OPERATION_TYPE | undefined; value?: string | undefined; idempotentId?: string | undefined; }[] | 消息属性。 |
| modifyContent.key | string | 表情回应消息,例如 OK/点赞/done 等。 |
| modifyContent.operation | im_proto.OPERATION_TYPE | undefined | 操作类型。 |
| modifyContent.value | string | undefined | 对应 content。也可以什么都不存,只代表有这个 key。 |
| modifyContent.idempotentId | string | undefined | 幂等 ID。通常为 user ID,防止对单个点赞动作重复操作。 |
返回值
类型: Promise<ModifyMessagePropertyResult>
设置消息属性结果。
获取指定单个本地会话。
类型
(params: { conversationId: string;}) => Conversation
ts参数
params
类型: { conversationId: string; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversationId | string | 会话 ID。 |
返回值
参看 Conversation。
请求服务端更新本地会话后,获取指定单个会话。
类型
(params: { conversationId: string; shortId: string; type: im_proto.ConversationType;}) => Promise<Conversation>
ts参数
params
类型: { conversationId: string; shortId: string; type: im_proto.ConversationType; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversationId | string | 会话 ID。 |
| shortId | string | shortId。 |
| type | im_proto.ConversationType | 会话类型。 |
返回值
参看 Conversation。
获取本地会话列表。
类型
(params?: { filter?: ((c: Conversation) => boolean) | undefined; }) => Conversation[]
ts参数
params
类型: { filter?: ((c: Conversation) => boolean) | undefined; }
默认值: ' {}'
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| filter | ((c: Conversation) => boolean) | undefined | 过滤条件,默认过滤陌生人会话和空会话。 |
请求服务端更新本地会话后,获取会话列表。直播群列表请使用 getLiveConversationListOnline。
类型
(params?: { filter?: ((c: Conversation) => boolean) | undefined; }) => Promise<Conversation[]>
ts参数
params
类型: { filter?: ((c: Conversation) => boolean) | undefined; }
默认值: ' {}'
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| filter | ((c: Conversation) => boolean) | undefined | 过滤条件,默认过滤陌生人会话和空会话。 |
从服务器获取会话内区间的消息,默认情况下从本地最早的消息开始拉取 (cursor = conversation.firstMessageIndex) (直播群不可用)
类型
(params: { conversation: Conversation; cursor?: string | Long | Message; direction?: number; limit?: number; limitIndex?: Long;}) => Promise<{ messages: Message[]; hasMore: boolean; cursor: Long; }>
ts注意
如果需要获得某个会话本地已有的消息,需调用 conversation.getMessageList()。
参数
params
类型: { conversation: Conversation; cursor?: string | Long | Message | undefined; direction?: number | undefined; limit?: number | undefined; limitIndex?: Long | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 会话信息。 |
| cursor | string | Long | Message | undefined | 拉取消息位置游标。 |
| direction | number | undefined | 拉取消息方向。 |
| limit | number | undefined | 拉取消息数量。 |
| limitIndex | Long | undefined | 保留参数,无意义。 |
返回值
会话内的消息列表,其中消息结构参看 Message。
请求服务器获取用户的会话列表。
类型
(params: { type: im_proto.ConversationType; inboxType?: number; cursor?: Long | string; limit?: number; sortType?: im_proto.SortType; includeRole?: number; excludeRole?: number; withCold?: boolean;}) => Promise<{ conversation: Conversation[]; hasMore: boolean; cursor: Long; }>
ts参数
params
类型: { type: im_proto.ConversationType; inboxType?: number | undefined; cursor?: string | Long | undefined; limit?: number | undefined; sortType?: im_proto.SortType | undefined; includeRole?: number | undefined; excludeRole?: number | undefined; withCold?: boolean | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| type | im_proto.ConversationType | 会话类型。 |
| inboxType | number | undefined | 信箱类型。 |
| cursor | string | Long | undefined | 拉取消息位置游标。 |
| limit | number | undefined | 单次拉取消息数量。 |
| sortType | im_proto.SortType | undefined | 排序类型。 |
| includeRole | number | undefined | 查询群聊类型时,包含的群聊角色,参看 GroupRole。 |
| excludeRole | number | undefined | 查询群聊类型时,排除的群聊角色,参看 GroupRole。 |
| withCold | boolean | undefined | 保留参数,无意义。 |
返回值
用户会话列表,其中会话结构参看 Conversation。
创建群聊。
类型
(params: { participants: string[] | string; bizExt?: { [k: string]: string; } | undefined; inboxType?: number | undefined; type?: im_proto.ConversationType | undefined; persistent?: boolean | undefined; idempotentId?: string | undefined; name?: string | undefined; avatarUrl?: string | undefined; desc?: string | undefined; }) => Promise<CreateConversationResult>
ts参数
params
类型: { participants: string[] | string; bizExt?: { [k: string]: string; } | undefined; inboxType?: number | undefined; type?: im_proto.ConversationType | undefined; persistent?: boolean | undefined; idempotentId?: string | undefined; name?: string | undefined; avatarUrl?: string | undefined; desc?: string | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| participants | string | string[] | 会话内的用户 ID。 |
| bizExt | { [k: string]: string; } | undefined | 业务拓展信息。 |
| inboxType | number | undefined | 信箱类型。 |
| type | im_proto.ConversationType | undefined | 会话类型。 |
| persistent | boolean | undefined | 持久化幂等,默认为 true,不建议修改。 |
| idempotentId | string | undefined | 幂等 ID。由业务方自己生成,以同样的幂等 ID 创建群聊会话时,会返回之前已经创建好的群聊会话。 |
| name | string | undefined | 群名称。 |
| avatarUrl | string | undefined | 群头像的 url 链接。 |
| desc | string | undefined | 群描述。 |
返回值
类型: Promise<CreateConversationResult>
创建结果。
离开群组。
类型
(params: { conversation: Conversation;}) => Promise<void>
ts参数
params
类型: { conversation: Conversation; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 会话信息。 |
删除会话。
类型
(params: { conversation: Conversation; localOnly?: boolean;}) => Promise<void>
ts参数
params
类型: { conversation: Conversation; localOnly?: boolean | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 待删除的会话。 |
| localOnly | boolean | undefined | 是否仅在本地删除,不同步到服务端。 默认值为 false,即本地和服务端均删除。 |
解散群聊。
类型
(params: { conversation: Conversation;}) => Promise<void>
ts参数
params
类型: { conversation: Conversation; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 会话信息。 |
设置会话附加信息,如置顶、免打扰、收藏等。
类型
(params: { conversation: Conversation; stickOnTop?: boolean; mute?: boolean; favorite?: boolean; pushStatus?: PushStatus;}) => Promise<SetConversationSettingInfoResult>
ts参数
params
类型: { conversation: Conversation; stickOnTop?: boolean | undefined; mute?: boolean | undefined; favorite?: boolean | undefined; pushStatus?: PushStatus | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 会话信息。 |
| stickOnTop | boolean | undefined | 是否置顶。 |
| mute | boolean | undefined | 是否免打扰。 |
| favorite | boolean | undefined | 是否收藏。 |
| pushStatus | PushStatus | undefined | 消息推送模式。 |
返回值
类型: Promise<SetConversationSettingInfoResult>
设置结果。
配置会话低打扰模式。
类型
(params: { conversation: Conversation; config: ConversationSettingWeakMuteInfo;}) => Promise<{ success: boolean; payload: Conversation; checkCode: Long; checkMsg: string; statusCode: number; statusMsg: string; }>
ts参数
params
类型: { conversation: Conversation; config: ConversationSettingWeakMuteInfo; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 会话信息。 |
| config | ConversationSettingWeakMuteInfo | 会话低打扰模式配置。 |
更新 Setting ext 拓展信息。
类型
(params: { conversation: Conversation; ext?: { [k: string]: string; } | undefined; }) => Promise<{ success: boolean; payload: Conversation; checkCode: Long; checkMsg: string; statusCode: number; statusMsg: string; }>
ts参数
params
类型: { conversation: Conversation; ext?: { [k: string]: string; } | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 会话信息。 |
| ext | { [k: string]: string; } | undefined | 拓展信息。 |
设置群聊信息。
类型
(params: { conversation: Conversation; name?: string | undefined; desc?: string | undefined; icon?: string | undefined; notice?: string | undefined; isNameSet?: boolean | undefined; isDescSet?: boolean | undefined; isIconSet?: boolean | undefined; isNoticeSet?: boolean | undefined; ext?: { [k: string]: string; } | undefined; bizExt?: { [k: string]: string; } | undefined;})=> Promise<SetConversationSettingInfoResult>
ts参数
params
类型: { conversation: Conversation; name?: string | undefined; desc?: string | undefined; icon?: string | undefined; notice?: string | undefined; isNameSet?: boolean | undefined; isDescSet?: boolean | undefined; isIconSet?: boolean | undefined; isNoticeSet?: boolean | undefined; ext?: { [k: string]: string; } | undefined; bizExt?: { [k: string]: string; } | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 会话信息。 |
| name | string | undefined | 群名称。 |
| desc | string | undefined | 群描述。 |
| icon | string | undefined | 群头像的 url 链接。 |
| notice | string | undefined | 群公告。 |
| isNameSet | boolean | undefined | 是否设置群名称。 |
| isDescSet | boolean | undefined | 是否设置群描述。 |
| isIconSet | boolean | undefined | 是否设置群头像。 |
| isNoticeSet | boolean | undefined | 是否设置群公告。 |
| ext | { [k: string]: string; } | undefined | 拓展信息。 |
| bizExt | { [k: string]: string; } | undefined | 业务拓展信息。 |
返回值
类型: Promise<SetConversationSettingInfoResult>
群聊信息设置结果。
更新 Core ext 拓展信息。
类型
(params: { conversation: Conversation; ext?: { [k: string]: string; } | undefined; }) => Promise<{ success: boolean; payload: Conversation; checkCode: Long; checkMsg: string; statusCode: number; statusMsg: string; }>
ts参数
params
类型: { conversation: Conversation; ext?: { [k: string]: string; } | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 会话信息。 |
| ext | { [k: string]: string; } | undefined | 拓展信息。 |
返回值
更新结果。
获取顶置会话。
类型
(params?: { cursor?: string | Long; limit?: number; inboxType?: number;}) => Promise<{ conversation: Conversation[]; hasMore: boolean; cursor: Long; }>
ts参数
params
类型: { cursor?: string | Long | undefined; limit?: number | undefined; inboxType?: number | undefined; }
默认值: ' {}'
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| cursor | string | Long | undefined | 拉取消息位置游标,默认值为 0。 |
| limit | number | undefined | 拉取消息数量。 |
| inboxType | number | undefined | 信箱类型。 |
返回值
获取到的会话,其中会话结构参看 Conversation。
获取收藏会话。
类型
(params?: { cursor?: string | Long; limit?: number; inboxType?: number;}) => Promise<{ conversation: Conversation[]; hasMore: boolean; cursor: Long; }>
ts参数
params
类型: { cursor?: string | Long | undefined; limit?: number | undefined; inboxType?: number | undefined; }
默认值: ' {}'
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| cursor | string | Long | undefined | 拉取消息位置游标,默认值为 0。 |
| limit | number | undefined | 拉取消息数量。 |
| inboxType | number | undefined | 信箱类型。 |
返回值
获取到的会话,其中会话结构参看 Conversation。
标记会话已读。
类型
(params: { conversation: Conversation; readIndex?: string | Long | Message; convUnreadCount?: number; totalUnreadCount?: number;}) => Promise<void>
ts参数
params
类型: { conversation: Conversation; readIndex?: string | Long | Message | undefined; convUnreadCount?: number | undefined; totalUnreadCount?: number | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 会话信息。 |
| readIndex | string | Long | Message | undefined | 消息的 indexInConversation。默认为会话的 lastMessageIndex(最后一条消息的 index)。 |
| convUnreadCount | number | undefined | 会话中未读消息数。 |
| totalUnreadCount | number | undefined | 总未读消息数。 |
添加群成员。
类型
(params: { conversation: Conversation; participant: Participant | Participant[] | string[] | string; bizExt?: { [k: string]: string; } | undefined; isDropReconnect?: boolean | undefined; _participantInfos?: { user_id?: Long | null | undefined; alias?: string | null | undefined; ext?: { [k: string]: string; } | null | undefined; avatar_url?: string | null | undefined; }[] | undefined; }) => Promise<AddParticipantResult>
ts参数
params
类型: { conversation: Conversation; participant: Participant | Participant[] | string[] | string; bizExt?: { [k: string]: string; } | undefined; isDropReconnect?: boolean | undefined; _participantInfos?: { user_id?: Long | null | undefined; alias?: string | null | undefined; ext?: { [k: string]: string; } | null | undefined; avatar_url?: string | null | undefined; }[] | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 会话信息。 |
| participant | string | string[] | Participant | Participant[] | 待添加的群成员 ID 列表。 |
| bizExt | { [k: string]: string; } | undefined | 业务拓展信息。 |
| isDropReconnect | boolean | undefined | 是否是掉线重连。若用户因网络波动等原因掉线,SDK 会在网络恢复后自动重连。 |
返回值
类型: Promise<AddParticipantResult>
添加成员结果。
移除群成员/离开直播群/移除直播群成员,v1.1.0 新增直播群功能。
类型
(params: { conversation: Conversation; participant: Participant | Participant[] | string | string[]; bizExt?: { [k: string]: string; } | undefined; }) => Promise<RemoveParticipantResult>
ts参数
params
类型: { conversation: Conversation; participant: Participant | Participant[] | string | string[]; bizExt?: { [k: string]: string; } | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 会话信息。 |
| participant | string | string[] | Participant | Participant[] | 待移除的群成员 ID 列表。 |
| bizExt | { [k: string]: string; } | undefined | 业务拓展信息。 |
返回值
类型: Promise<RemoveParticipantResult>
移除成员结果。
更新群成员信息。
类型
(params: { conversation: Conversation; userId: string; role?: number | undefined; alias?: string | undefined; avatarUrl?: string | undefined; bizExt?: { [k: string]: string; } | undefined; }) => Promise<UpdateParticipantResult>
ts参数
params
类型: { conversation: Conversation; userId: string; role?: number | undefined; alias?: string | undefined; avatarUrl?: string | undefined; bizExt?: { [k: string]: string; } | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 会话信息。 |
| userId | string | 成员的用户 ID。 |
| role | number | undefined | 成员角色。 0 为普通成员,1 为群主。 |
| alias | string | undefined | 成员群昵称。 |
| avatarUrl | string | undefined | 成员头像(直播群适用) |
| bizExt | { [k: string]: string; } | undefined | 业务拓展信息。 |
返回值
类型: Promise<UpdateParticipantResult>
更新结果。
获取 SDK 本地维护的群成员列表。
类型
(params: { conversation: Conversation;}) => Participant[]ts
参数
params
类型: { conversation: Conversation; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 会话信息。 |
获取群成员列表。
此方法会在 SDK 内部循环调用分页接口,直至没有更多数据,然后把所有群成员数据一次返回。当群成员较多时,此方法耗时较久。
类型
(params: { conversation: Conversation; limit?: number; cursor?: Long;}) => Promise<{ participants: Participant[]; hasMore: boolean; cursor: Long; }>
ts参数
params
类型: { conversation: Conversation; limit?: number | undefined; cursor?: Long | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 会话信息。 |
| limit | number | undefined | 单页拉取消息数量。 |
| cursor | Long | undefined | 下一页拉取消息位置游标。 |
返回值
群成员列表,其中成员结构参看 Participant。
设置群禁言(会话维度)。
类型
(params: { conversation: Conversation; block: boolean; normalOnly?: boolean;}) => Promise<Conversation>
ts参数
params
类型: { conversation: Conversation; block: boolean; normalOnly?: boolean | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 会话信息。 |
| block | boolean | 是否禁言。 |
| normalOnly | boolean | undefined | 是否只禁言普通群成员。 |
返回值
参看 Conversation。
设置群禁言(成员维度)。
类型
(params: { conversation: Conversation; block: boolean; blockDuration: { [k: string]: string | number | Long; }; bizExt?: { [k: string]: string; } | undefined; }) => Promise<Conversation>
ts参数
params
类型: { conversation: Conversation; block: boolean; blockDuration: { [k: string]: string | number | Long; }; bizExt?: { [k: string]: string; } | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 会话信息。 |
| block | boolean | 是否禁言。 |
| blockDuration | { [k: string]: string | number | Long; } | 禁言用户和时间。key 是用户 ID;value 是禁言时间,单位为秒。{111: 1000} 表示把用户 111 禁言 1000 秒。 |
| bizExt | { [k: string]: string; } | undefined | 业务拓展信息。 |
返回值
参看 Conversation。
手动卸载 SDK。
类型
() => void
ts类型: class
多媒体消息插件,在 IM 实例化时传入后,IM 实例增加发送媒体消息的方法。
| 方法 | 描述 |
|---|---|
| createImageMessage | 创建图片消息。 |
| createAudioMessage | 创建音频消息。 |
| createVideoMessage | 创建视频消息。 |
| createFileMessage | 创建文件消息。 |
| refreshFileUrl | 根据消息内容刷新文件 URL。 |
| validateFileUrl | 校验文件 URL 是否在有效期。 |
| getImageResizeUrls | 获取图片 URL(缩放、转码)。 |
创建图片消息。
类型
(params: { conversation: Conversation; fileInfo: FileInfo; clientId?: string | undefined; ext?: { [k: string]: string; } | undefined; mentionedUsers?: string[] | undefined; insert?: boolean | undefined; referenceMessage?: Message | undefined; referenceHint?: string | undefined; }) => Promise<Message>
ts参数
params
类型: { conversation: Conversation; fileInfo: FileInfo; clientId?: string | undefined; ext?: { [k: string]: string; } | undefined; mentionedUsers?: string[] | undefined; insert?: boolean | undefined; referenceMessage?: Message | undefined; referenceHint?: string | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 会话信息。 |
| fileInfo | FileInfo | 文件信息。 |
| clientId | string | undefined | 客户端 ID。 |
| ext | { [k: string]: string; } | undefined | 消息拓展属性。 |
| mentionedUsers | string[] | undefined | 需要 @ 的用户列表。 |
| insert | boolean | undefined | 消息创建后是否 process 处理(新消息处理流程)。 |
| referenceMessage | Message | undefined | 引用的消息。 |
| referenceHint | string | undefined | 业务透传的引用信息,传入自定义引用线索。 |
返回值
创建的消息,参看 Message。
创建音频消息。
类型
(params: { conversation: Conversation; fileInfo: FileInfo; clientId?: string | undefined; ext?: { [k: string]: string; } | undefined; mentionedUsers?: string[] | undefined; insert?: boolean | undefined; referenceMessage?: Message | undefined; referenceHint?: string | undefined; }) => Promise<Message>
ts参数
params
类型: { conversation: Conversation; fileInfo: FileInfo; clientId?: string | undefined; ext?: { [k: string]: string; } | undefined; mentionedUsers?: string[] | undefined; insert?: boolean | undefined; referenceMessage?: Message | undefined; referenceHint?: string | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 会话信息。 |
| fileInfo | FileInfo | 文件信息。 |
| clientId | string | undefined | 客户端 ID。 |
| ext | { [k: string]: string; } | undefined | 消息拓展属性。 |
| mentionedUsers | string[] | undefined | 需要 @ 的用户列表。 |
| insert | boolean | undefined | 消息创建后是否 process 处理(新消息处理流程)。 |
| referenceMessage | Message | undefined | 引用的消息。 |
| referenceHint | string | undefined | 业务透传的引用信息,传入自定义引用线索。 |
返回值
创建的消息,参看 Message。
创建视频消息。
类型
(params: { conversation: Conversation; fileInfo: FileInfo; clientId?: string | undefined; ext?: { [k: string]: string; } | undefined; mentionedUsers?: string[] | undefined; insert?: boolean | undefined; referenceMessage?: Message | undefined; referenceHint?: string | undefined; }) => Promise<Message>
ts参数
params
类型: { conversation: Conversation; fileInfo: FileInfo; clientId?: string | undefined; ext?: { [k: string]: string; } | undefined; mentionedUsers?: string[] | undefined; insert?: boolean | undefined; referenceMessage?: Message | undefined; referenceHint?: string | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 会话信息。 |
| fileInfo | FileInfo | 文件信息。 |
| clientId | string | undefined | 客户端 ID。 |
| ext | { [k: string]: string; } | undefined | 消息拓展属性。 |
| mentionedUsers | string[] | undefined | 需要 @ 的用户列表。 |
| insert | boolean | undefined | 消息创建后是否 process 处理(新消息处理流程)。 |
| referenceMessage | Message | undefined | 引用的消息。 |
| referenceHint | string | undefined | 业务透传的引用信息,传入自定义引用线索。 |
返回值
创建的消息,参看 Message。
创建文件消息。
类型
(params: { conversation: Conversation; fileInfo: FileInfo; clientId?: string | undefined; ext?: { [k: string]: string; } | undefined; mentionedUsers?: string[] | undefined; insert?: boolean | undefined; referenceMessage?: Message | undefined; referenceHint?: string | undefined; }) => Promise<Message>
ts参数
params
类型: { conversation: Conversation; fileInfo: FileInfo; clientId?: string | undefined; ext?: { [k: string]: string; } | undefined; mentionedUsers?: string[] | undefined; insert?: boolean | undefined; referenceMessage?: Message | undefined; referenceHint?: string | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 会话信息。 |
| fileInfo | FileInfo | 文件信息。 |
| clientId | string | undefined | 客户端 ID。 |
| ext | { [k: string]: string; } | undefined | 消息拓展属性。 |
| mentionedUsers | string[] | undefined | 需要 @ 的用户列表。 |
| insert | boolean | undefined | 消息创建后是否 process 处理(新消息处理流程)。 |
| referenceMessage | Message | undefined | 引用的消息。 |
| referenceHint | string | undefined | 业务透传的引用信息,传入自定义引用线索。 |
返回值
创建的消息,参看 Message。
根据消息内容刷新文件 URL。
类型
(params: { message: Message; ignoreCache?: boolean;}) => Promise<Message>
ts参数
params
类型: { message: Message; ignoreCache?: boolean | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| message | Message | 消息内容。 |
| ignoreCache | boolean | undefined | 是否忽略缓存。 |
返回值
参看 Message。
校验文件 URL 是否在有效期。
类型
(params: { message: Message; delta?: number;}) => boolean
ts参数
params
类型: { message: Message; delta?: number | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| message | Message | 消息内容 |
| delta | number | undefined | 有效期偏移量,单位秒,默认提前30s认定过期 |
返回值
类型: boolean
获取图片 URL(缩放、转码)。
类型
(params: { uri: string; format?: string; width: number; height: number;}) => Promise<string[]>
ts参数
params
类型: { uri: string; format?: string | undefined; width: number; height: number; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| uri | string | 图片 URI。 |
| format | string | undefined | 图片格式,目前支持 jpeg, png, webp, gif。 |
| width | number | 图片宽度。 |
| height | number | 图片高度。 |
返回值
类型: Promise<string[]>
图片 URL。
类型: class
直播群插件,在 IM 实例化时传入后,IM 实例增加直播群相关的方法。v1.1.0 新增。
| 方法 | 描述 |
|---|---|
| joinLiveGroup | 加入直播群,加入成功时会启动直播 ping 和断线恢复重进(接口基于 addParticipants) |
| leaveLiveGroup | 离开直播群,并且会停止直播 ping(接口基于 removeParticipants) |
| setParticipantBlockTime | 拉黑直播群成员。 |
| getMuteParticipantsOnline | 获取直播群禁言成员列表。 |
| getBlockParticipantsOnline | 获取直播群被拉黑成员列表。 |
| getLiveParticipantMuteWhiteListOnline | 获取直播群禁言白名单。 |
| addLiveParticipantMuteWhiteList | 添加指定成员到直播群禁言白名单。 |
| removeLiveParticipantMuteWhiteList | 从直播群禁言白名单移除指定成员。 |
| getLiveConversationListOnline | 获取直播群列表。 |
| getLiveParticipantsOnline | 获取直播群在线成员列表。 |
| getLiveParticipantCountOnline | 获取直播群在线人数 |
| getLiveParticipantInfoOnline | 获取直播群指定成员状态信息(例如是否在线、最后活跃时间),v1.1.2 新增。 |
| getLiveParticipantDetailOnline | 获取直播群指定成员资料(例如成员在群中的昵称、头像),v1.5.0 新增。 |
| getLiveGroupHistoryMessageListOnline | 获取直播群历史消息 |
| updateLiveConversationMarks | 更新直播群内的标记类型 |
| getLiveConversationMarksOnline | 获取直播群内的标记类型 |
| updateLiveParticipantsMarks | 更新直播群内指定成员的标记,需要先在群中创建好对应标记类型 |
加入直播群,加入成功时会启动直播 ping 和断线恢复重进(接口基于 addParticipants)
类型
(params: { conversation: Conversation; bizExt?: { [key: string]: string; } | undefined; avatarUrl?: string | undefined; alias?: string | undefined; participantExt?: { [k: string]: string; } | undefined; }) => Promise<...>
ts参数
params
类型: { conversation: Conversation; bizExt?: { [key: string]: string; } | undefined; avatarUrl?: string | undefined; alias?: string | undefined; participantExt?: { [k: string]: string; } | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 直播群 |
| bizExt | { [key: string]: string; } | undefined | 业务拓展信息 |
| avatarUrl | string | undefined | 进群后自己的群头像 |
| alias | string | undefined | 进群后自己的群昵称 |
| participantExt | { [k: string]: string; } | undefined | 进群后自己的成员信息扩展字段 |
返回值
添加成员结果。
离开直播群,并且会停止直播 ping(接口基于 removeParticipants)
类型
(params: { conversation: Conversation; bizExt?: { [key: string]: string; } | undefined; }) => Promise<RemoveParticipantResult>
ts参数
params
类型: { conversation: Conversation; bizExt?: { [key: string]: string; } | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 直播群 |
| bizExt | { [key: string]: string; } | undefined | 业务拓展信息 |
返回值
移除成员结果。
拉黑直播群成员。
类型
(params: { conversation: Conversation; block: boolean; blockDuration: { [k: string]: string | number | Long; }; bizExt?: { [k: string]: string; } | undefined; }) => Promise<im_proto.IBlockMembersResponseBody | null | undefined>
ts参数
params
类型: { conversation: Conversation; block: boolean; blockDuration: { [k: string]: string | number | Long; }; bizExt?: { [k: string]: string; } | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 会话信息。 |
| block | boolean | 是否拉黑。 |
| blockDuration | { [k: string]: string | number | Long; } | 用户ID/拉黑时长。 |
| bizExt | { [k: string]: string; } | undefined |
返回值
拉黑的消息。
获取直播群禁言成员列表。
类型
(params: { conversation: Conversation; limit?: number; cursor?: Long;}) => Promise<{ participants: any; hasMore: any; cursor: any; }>
ts参数
params
类型: { conversation: Conversation; limit?: number | undefined; cursor?: Long | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 直播群信息。 |
| limit | number | undefined | 每页多少条,默认20条。 |
| cursor | Long | undefined | 游标。 |
返回值
成员列表信息。
获取直播群被拉黑成员列表。
类型
(params: { conversation: Conversation; limit?: number; cursor?: Long;}) => Promise<{ participants: any; hasMore: any; cursor: any; }>
ts参数
params
类型: { conversation: Conversation; limit?: number | undefined; cursor?: Long | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 直播群信息。 |
| limit | number | undefined | 每页多少条,默认20条。 |
| cursor | Long | undefined | 游标。 |
返回值
成员列表信息。
获取直播群禁言白名单。
类型
(params: { conversation: Conversation; cursor?: Long; limit?: number;}) => Promise<{ participants: any; hasMore: any; cursor: any; }>
ts参数
params
类型: { conversation: Conversation; cursor?: Long | undefined; limit?: number | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 需要获取的直播群 |
| cursor | Long | undefined | 游标。 |
| limit | number | undefined | 每页多少条,默认20条。 |
返回值
直播群禁言白名单。
添加指定成员到直播群禁言白名单。
类型
(params: { conversation: Conversation; participantIds: string[];}) => Promise<{ failedParticipantIds: string[]; }>
ts参数
params
类型: { conversation: Conversation; participantIds: string[]; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 直播群 |
| participantIds | string[] | 成员 ID |
返回值
添加失败的成员 ID。
从直播群禁言白名单移除指定成员。
类型
(params: { conversation: Conversation; participantIds: string[];}) => Promise<{ failedParticipantIds: string[]; }>
ts参数
params
类型: { conversation: Conversation; participantIds: string[]; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 直播群 |
| participantIds | string[] | 成员 ID |
返回值
移除失败的成员 ID。
获取直播群列表。
类型
(params: { cursor?: Long; policy?: number; limit?: number;}) => Promise<{ conversation: any; hasMore: any; cursor: any; }>
ts参数
params
类型: { cursor?: Long | undefined; policy?: number | undefined; limit?: number | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| cursor | Long | undefined | 游标。 |
| policy | number | undefined | 过滤条件 1: 所有的群 3: 自己是群主的群。默认返回所有群。 |
| limit | number | undefined | 每页多少条,默认20条。 |
返回值
直播群列表信息。
获取直播群在线成员列表。
类型
(params: { conversation: Conversation; limit?: number; cursor?: Long; markType?: string;}) => Promise<{ participants: any; hasMore: any; cursor: any; }>
ts参数
params
类型: { conversation: Conversation; limit?: number | undefined; cursor?: Long | undefined; markType?: string | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 直播群信息。 |
| limit | number | undefined | 每页多少条,默认20条。 |
| cursor | Long | undefined | 游标。 |
| markType | string | undefined | 成员标记 |
返回值
在线成员列表信息。
获取直播群在线人数
类型
(params: { conversation: Conversation;}) => Promise<{ count: number; }>
ts参数
params
类型: { conversation: Conversation; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 直播群信息。 |
返回值
在线人数
获取直播群指定成员状态信息(例如是否在线、最后活跃时间),v1.1.2 新增。
类型
(params: { conversation: Conversation; participantIds: string[];}) => Promise<Record<string, im_proto.IMemberInfo | undefined>>
ts参数
params
类型: { conversation: Conversation; participantIds: string[]; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 直播群 |
| participantIds | string[] | 要查询的用户 ID |
返回值
类型: Promise<Record<string, im_proto.IMemberInfo | undefined>>
直播群指定成员状态信息。
获取直播群指定成员资料(例如成员在群中的昵称、头像),v1.5.0 新增。
类型
({ conversation, participantIds }: { conversation: Conversation; participantIds: string[];}) => Promise<Participant[]>
ts参数
{conversation, participantIds}
类型: { conversation: Conversation; participantIds: string[]; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 直播群 |
| participantIds | string[] | 要查询的用户 ID |
返回值
类型: Promise<Participant[]>
直播群指定成员资料。
获取直播群历史消息
类型
(params: { conversation: Conversation; limit?: number; fromIndex?: Long; direction?: im_proto.MessageDirection;}) => Promise<{ messages: Message[]; hasMore: boolean; nextIndex: Long; }>
ts参数
params
类型: { conversation: Conversation; limit?: number | undefined; fromIndex?: Long | undefined; direction?: im_proto.MessageDirection | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 直播群信息。 |
| limit | number | undefined | 每页多少条,默认 20 条。 |
| fromIndex | Long | undefined | 查询起始下标,默认为 Long.MAX_VALUE(配合查询方向) |
返回值
对应区间消息列表和下一页起始下标
更新直播群内的标记类型
类型
(params: { markAction?: im_proto.MarkAction; conversation: Conversation; markTypes: string[];}) => Promise<{}>
ts参数
params
类型: { markAction?: im_proto.MarkAction | undefined; conversation: Conversation; markTypes: string[]; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| markAction | im_proto.MarkAction | undefined | 标记操作(添加或删除) |
| conversation | Conversation | 直播群 |
| markTypes | string[] | 标记类型 |
返回值
(无数据返回)
获取直播群内的标记类型
类型
(params: { conversation: Conversation;}) => Promise<{ markTypes: string[] | null | undefined; }>
ts参数
params
类型: { conversation: Conversation; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| conversation | Conversation | 直播群 |
返回值
群里已有的标记类型
更新直播群内指定成员的标记,需要先在群中创建好对应标记类型
类型
(params: { markAction?: im_proto.MarkAction; conversation: Conversation; participantIds: string[]; markTypes: string[];}) => Promise<{ checkCode: Long; checkMsg: string; failedParticipant: string[]; rawResp: im_proto.IBatchUpdateConversationParticipantResponseBody | null | undefined; }>
ts参数
params
类型: { markAction?: im_proto.MarkAction | undefined; conversation: Conversation; participantIds: string[]; markTypes: string[]; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| markAction | im_proto.MarkAction | undefined | 标记操作(添加或删除) |
| conversation | Conversation | 直播群 |
| participantIds | string[] | 成员 ID |
| markTypes | string[] | 标记类型 |
返回值
操作结果(例如失败的成员)
类型: class
联系人插件,提供好友关系等能力;在 IM 实例化时传入后,IM 实例增加联系人相关的方法。v1.2.0 新增。
| 方法 | 描述 |
|---|---|
| getFriendReceiveApplyListOnline | 获取好友申请列表。 |
| getFriendListOnline | 获取好友列表。 |
| applyFriend | 申请添加好友。 |
| deleteFriend | 删除好友。 |
| replyFriendApply | 回应好友申请。 |
| markFriendReceiveApplyAsRead | 标记好友申请已读。(用于同步申请未读数等场景) |
| addUserToBlack | 将指定用户加入黑名单 |
| removeUserFromBlack | 将指定用户从黑名单移除 |
| userIsInMyBlack | 检查用户是否在黑名单中 |
| updateBlackUserState | 更新指定用户黑名单条目(例如更新 ext) |
| getBlacklistOnline | 获取用户黑名单 |
| updateFriend | 更新好友信息 |
| getUserProfilesOnline | 获取用户资料 |
| setUserProfile | 设置用户资料 |
获取好友申请列表。
类型
(params: { cursor?: Long; limit?: number; direction?: im_proto.MessageDirection;}) => Promise<{ list: FriendApply[]; totalCount: number; cursor: Long | null | undefined; hasMore: boolean | null | undefined; unreadCount: number; }>
ts参数
params
类型: { cursor?: Long | undefined; limit?: number | undefined; direction?: im_proto.MessageDirection | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| cursor | Long | undefined | 分页游标,首页拉取可使用 0。 |
| limit | number | undefined | 查询条数,默认 20 条。 |
| direction | im_proto.MessageDirection | undefined | 拉取方向,默认从新到旧。 |
返回值
好友申请列表与分页信息,其中好友申请列表参看 FriendApply。
获取好友列表。
类型
(params: { cursor?: Long; limit?: number;}) => Promise<{ list: Friend[]; totalCount: number; cursor: Long | null | undefined; hasMore: boolean | null | undefined; }>
ts参数
params
类型: { cursor?: Long | undefined; limit?: number | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| cursor | Long | undefined | 分页游标,首页拉取可使用 0。 |
| limit | number | undefined | 查询条数,默认 20 条。 |
返回值
好友列表与分页信息,其中好友信息参看 Friend。
申请添加好友。
类型
({ userId, ext }: { userId: string; ext?: { [key: string]: string; } | undefined; }) => Promise<{ status: number | null | undefined; checkCode: Long | null | undefined; checkMessage: string | null | undefined; index: Long | null | undefined; applyId: string | null | undefined; }>
ts参数
{ userId, ext }
类型: { userId: string; ext?: { [key: string]: string; } | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| userId | string | 接收方用户 ID。 |
| ext | { [key: string]: string; } | undefined | 业务扩展字段。 |
返回值
申请添加好友结果。
删除好友。
类型
({ userIds }: { userIds: string[];}) => Promise<{ failedInfos: { failedReason: string; failedCode: im_proto.StatusCode; failedUserId: string; }[]; }>
ts参数
{userIds}
类型: { userIds: string[]; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| userIds | string[] | 需要删除的用户 ID。 |
返回值
删除失败列表。
回应好友申请。
类型
(params: { userId: string; attitude: ReplyFriendAttitude; ext?: { [key: string]: string; } | undefined; }) => Promise<{ failedInfos: { failedReason: string; failedCode: im_proto.StatusCode; failedUserId: string; }[]; }>
ts参数
params
类型: { userId: string; attitude: ReplyFriendAttitude; ext?: { [key: string]: string; } | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| userId | string | 回复的申请用户 ID。 |
| attitude | ReplyFriendAttitude | 好友申请回应状态。 |
| ext | { [key: string]: string; } | undefined | 业务扩展字段。 |
返回值
回复失败列表。
标记好友申请已读。(用于同步申请未读数等场景)
类型
({ readIndex }: { readIndex: Long;}) => Promise<void>
ts参数
{readIndex}
类型: { readIndex: Long; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| readIndex | Long | 已读取的申请下标。 |
将指定用户加入黑名单
类型
({ userIds, ext }: { userIds: string[]; ext?: { [key: string]: string; } | undefined; }) => Promise<{ failedInfos: { failedReason: string; failedCode: im_proto.StatusCode; failedUserId: string; }[]; }>
ts参数
{userIds, ext}
类型: { userIds: string[]; ext?: { [key: string]: string; } | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| userIds | string[] | 用户 ID |
| ext | { [key: string]: string; } | undefined | 业务扩展字段。 |
返回值
请求失败的列表
将指定用户从黑名单移除
类型
({ userIds, }: { userIds: string[];}) => Promise<{ failedInfos: { failedReason: string; failedCode: im_proto.StatusCode; failedUserId: string; }[]; }>
ts参数
{ userIds, }
类型: { userIds: string[]; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| userIds | string[] | 用户 ID |
返回值
请求失败的列表
检查用户是否在黑名单中
类型
({ userIds, }: { userIds: string[];}) => Promise<{ [k: string]: boolean; }>
ts参数
{ userIds, }
类型: { userIds: string[]; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| userIds | string[] | 用户 ID |
返回值
字典对象,key 为用户 ID,value 为是否在黑名单中
更新指定用户黑名单条目(例如更新 ext)
类型
({ userIds, ext }: { userIds: string[]; ext?: { [key: string]: string; } | undefined; }) => Promise<{ failedInfos: { failedReason: string; failedCode: im_proto.StatusCode; failedUserId: string; }[]; }>
ts参数
{userIds, ext}
类型: { userIds: string[]; ext?: { [key: string]: string; } | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| userIds | string[] | 用户 ID |
| ext | { [key: string]: string; } | undefined | 业务扩展字段。 |
返回值
请求失败的列表
获取用户黑名单
类型
(params: { cursor?: Long; limit?: number; direction?: im_proto.MessageDirection;}) => Promise<{ list: BlackUserInfo[]; totalCount: number; cursor: Long | null | undefined; hasMore: boolean | null | undefined; }>
ts参数
params
类型: { cursor?: Long | undefined; limit?: number | undefined; direction?: im_proto.MessageDirection | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| cursor | Long | undefined | 分页游标,首页拉取可使用 0。 |
| limit | number | undefined | 查询条数,默认 20 条。 |
| direction | im_proto.MessageDirection | undefined | 拉取方向,默认从新到旧。 |
返回值
黑名单列表与分页信息
更新好友信息
类型
({ userId, ext, alias }: { userId: string; ext?: { [key: string]: string; } | undefined; alias?: string | undefined; }) => Promise<void>
ts参数
{userId, ext, alias}
类型: { userId: string; ext?: { [key: string]: string; } | undefined; alias?: string | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| userId | string | 要修改的好友用户 ID |
| ext | { [key: string]: string; } | undefined | 好友信息扩展字段 |
| alias | string | undefined | 好友备注 |
返回值
(无数据返回)
获取用户资料
类型
({ userIds }: { userIds: string[];}) => Promise<{ list: UserProfile[]; failedUids: string[]; }>
ts参数
{userIds}
类型: { userIds: string[]; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| userIds | string[] | 用户 ID |
设置用户资料
类型
(profile: { nickname?: string | undefined; portrait?: string | undefined; ext?: { [k: string]: string; } | undefined; }) => Promise<{ profile: UserProfile | null; }>
ts参数
profile
类型: { nickname?: string | undefined; portrait?: string | undefined; ext?: { [k: string]: string; } | undefined; }
成员
| 名称 | 类型 | 描述 |
|---|---|---|
| nickname | string | undefined | 昵称 |
| portrait | string | undefined | 头像 |
| ext | { [k: string]: string; } | undefined | 业务自定义扩展字段 |
类型: class
| 方法 | 描述 |
|---|---|
| subscribe | 创建一个事件订阅 |
| unsubscribe | 取消一个事件订阅 |
创建一个事件订阅
类型
<T extends keyof IMEventTypeMap>(event: T, func: EventHandler<IMEventTypeMap[T]>) => Subscription<IMEventTypeMap[T]>
ts参数
event
类型: T
事件类型,参看 IMEvent。
func
类型: EventHandler<IMEventTypeMap[T]>
事件回调函数。
返回值
类型: Subscription<IMEventTypeMap[T]>
回调函数 Index
取消一个事件订阅
类型
(event: IMEvent, handler: Subscription<any>) => void
ts参数
event
类型: IMEvent
事件类型
handler
类型: Subscription<any>
回调函数 Index