Options
All
  • Public
  • Public/Protected
  • All
Menu

RongIMLib - v5.10.4

Index

基础

会话

消息

聊天室

超级群

会话未读数

标签

草稿

黑名单

订阅用户状态

用户资料

Enum

Interface

Type

其他

基础

connect

  • connect(token: string, reconnectKickEnable?: boolean): Promise<IAsyncRes<{ userId: string }>>
  • 建立 IM 连接

    description

    传入从用户身份令牌(Token),向融云聊天服务器发起连接请求。

    • 注意
    1. 必须在 SDK 初始化 init 之后,调用 connect() 方法进行连接。否则可能没有回调。
    2. SDK 本身有重连机制,在一个应用生命周期内不须多次调用connect()
    3. 在应用生命周期调用一次即可。
    example

    建立 IM 连接示例:

    const token = '<Your-token>';
    const res = await RongIMLib.connect(token);
    console.info('建立 IM 连接结果:', res);

    Parameters

    • token: string
    • Optional reconnectKickEnable: boolean

      设置断线重连时是否踢出当前正在重连的设备 (仅 Electron 环境有效) 默认仅允许同一用户账号在单台桌面端设备上登录。后登录的 Electron 设备一旦连接成功,则自动踢出之前登录的设备。在部分情况下,SDK 的重连机制可能会导致后登录设备无法正常在线

    Returns Promise<IAsyncRes<{ userId: string }>>

disconnect

  • disconnect(closeDB?: boolean): Promise<void>
  • 断开连接

    description

    调用后将不再接收消息,不可发送消息,不可获取历史消息,不可获取会话列表

    • 适用场景:注销账号,切换账号时,推荐使用此方法
    example

    断开连接示例:

    await RongIMLib.disconnect();
    console.info('成功断开');

    Parameters

    • Optional closeDB: boolean

      是否关闭数据库,默认为 true,仅 Electron 平台有效

    Returns Promise<void>

addEventListener

  • addEventListener<T>(eventType: T, listener: EventListeners[T], target?: any): void
  • 添加监听器

    description

    用来接收来自于 IMLib 内的各种事件通知,同类型事件可以多次添加不同的监听函数。绑定仅执行一次的事件可以使用 onceEventListener

    example

    添加监听器示例:

    RongIMLib.addEventListener(RongIMLib.Events.CONNECTED, () => {
    console.log('连接成功');
    });

    Type parameters

    Parameters

    • eventType: T

      事件名称

    • listener: EventListeners[T]

      事件监听函数

    • Optional target: any

    Returns void

onceEventListener

  • onceEventListener<T>(eventType: T, listener: EventListeners[T], target?: any): void
  • 添加监听器(仅执行一次)

    description

    用来接收来自于 IMLib 内的各种事件通知

    example

    添加监听器示例:

    RongIMLib.onceEventListener(RongIMLib.Events.CONNECTED, () => {
    console.log('连接成功');
    });

    Type parameters

    Parameters

    • eventType: T

      事件名称

    • listener: EventListeners[T]

      事件监听函数

    • Optional target: any

    Returns void

removeEventListener

  • removeEventListener<T>(eventType: T, listener: EventListeners[T], target?: any): void
  • 移除事件

    description

    业务层需注意在必要时使用 removeEventListenerremoveEventListeners 移除对指定事件的监听函数,以免造成内存泄露

    example

    移除事件示例:

    const listener = (evt) => console.log(evt.messages)
    RongIMLib.removeEventListener(Events.MESSAGES, listener);

    Type parameters

    Parameters

    • eventType: T

      事件名称

    • listener: EventListeners[T]

      事件监听函数

    • Optional target: any

    Returns void

removeEventListeners

  • removeEventListeners(eventType: string): void
  • 移除同一类型下的所有事件

    description

    将移除对某一特定事件的所有监听函数

    example

    移除事件示例:

    RongIMLib.removeEventListeners(Events.MESSAGES);
    

    Parameters

    • eventType: string

      事件名称

    Returns void

clearEventListeners

  • clearEventListeners(): void
  • 清理所有事件

    example

    清理所有事件示例:

    RongIMLib.clearEventListeners();
    

    Returns void

init

  • 初始化

    description

    初始化 IM SDK,传入 Appkey 及相关配置信息

    example

    初始化示例:

    RongIMLib.init({ appkey: 'appkey' });
    console.log('初始化完成');

    Parameters

    Returns void

destroy

  • destroy(): Promise<void>
  • 反初始化

    description

    反初始化,清空所有监听及计时器,停止日志上报等业务

    • 适用场景
    1. 应用退出时,推荐使用此方法
    2. 需要更换 appkey 时,需要调用此方法后,重新使用新 Appkey 在次调用 init 方法
    example

    反初始化示例:

    await RongIMLib.destroy();
    console.log('反初始化完成');

    Returns Promise<void>

getConnectionStatus

  • 获取 IM 连接状态

    example

    获取 IM 连接状态示例:

    const status = RongIMLib.getConnectionStatus();
    console.log('获取 IM 连接状态:', status);

    Returns RCConnectionStatus

getCurrentUserId

  • getCurrentUserId(): string
  • 获取 IM 连接用户的 id

    example

    获取当前用户 id 示例:

    const userId = RongIMLib.getCurrentUserId();
    console.log('获取当前用户 id:', userId);

    Returns string

getDeviceId

  • getDeviceId(): string
  • 获取 deviceId

    description

    获取当前设备的唯一标识

    example

    获取 deviceId 示例:

    const deviceId = RongIMLib.getDeviceId();
    console.log('获取 deviceId:', deviceId);

    Returns string

installPlugin

  • installPlugin<T, O>(plugin: IPluginGenerator<T, O>, options: O): T | null
  • 装载 plugin 插件

    description

    装载 plugin 插件,需在调用 connect 方法之前使用,并返回相应的插件实例

    Type parameters

    • T

    • O

    Parameters

    • plugin: IPluginGenerator<T, O>
    • options: O

      插件配置

    Returns T | null

ConnectType

ConnectType: { COMET: string; WEBSOCKET: string } = ...
deprecated

从 5.6.0 版本开始,此定义失效

Type declaration

  • COMET: string
  • WEBSOCKET: string

会话

getConversationList

  • 获取会话列表

    description

    获取会话列表接口需要开通单群聊消息云存储之后才可以从服务端获取到数据,服务端会话列表存储上限为 1000

    • 注意: Electron 平台调用时会忽略参数传值,固定返回所有会话列表。建议 Electron 平台客户考虑使用其他获取会话列表的接口 超过 1000 会根据最后一条消息时间排序,删除最早的会话
    defaultvalues

    count: 20, startTime: 0, order: 0

    example

    获取会话列表示例:

    const conversationList = await RongIMLib.getConversationList();
    console.info('获取会话列表结果:', conversationList);

    Parameters

    • Optional options: { count?: number; startTime?: number; order?: 0 | 1 }

      获取会话列表参数配置

      • Optional count?: number

        会话数量

      • Optional startTime?: number

        获取起始时间 默认值: 0 order 为 0 startTime 默认值为当前时间 order 为 1 startTime 默认值为所有会话中最早的消息时间

      • Optional order?: 0 | 1

        默认值: 0 0 获取 startTime 之前的 1 获取 startTime 之后的

    • Optional channelId: string

    Returns Promise<IAsyncRes<IAReceivedConversation[]>>

    返回一个 IAsyncRes 类型 Promise,data 结构为 IAReceivedConversation 类型数组

getConversation

  • 获取指定会话数据

    description

    通过该方法获取的会话可能并不存在于当前的会话列表中,此处只作为功能性封装语法糖

    example

    获取指定会话数据示例:

    const options = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    }
    const conversation = await RongIMLib.getConversation(options);
    console.info('获取指定会话数据结果:', conversation);

    Parameters

    Returns Promise<IAsyncRes<IAReceivedConversation | null | undefined>>

    返回一个 IAsyncRes 类型 Promise,data 结构为 IAReceivedConversation 类型

removeConversation

  • 移除指定的会话

    description

    移除指定的会话,不会删除会话内的消息

    • 注意
    1. 删除会话不会删除会话的未读数,推荐在删除会话前先调用清除指定会话未读数 clearMessagesUnreadStatus接口,以防止未读数异常
    2. 会话是有消息生成,如会话中在产生新消息会重新生成会话
    example

    移除指定的会话示例:

    const options = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    }
    const conversation = await RongIMLib.removeConversation(options);
    console.info('移除指定的会话结果:', conversation);

    Parameters

    Returns Promise<IAsyncRes<void>>

setConversationNotificationLevel

  • 设置会话免打扰

    description

    支持按照 NotificationLevel 类型进行免打扰级别设置,级别描述如下:

    • -1: 全部消息通知(接收全部消息通知 -- 显示指定关闭免打扰功能)
    • 0: 未设置(向上查询群或者APP级别设置)//存量数据中0表示未设置
    • 1: 群聊超级群仅@消息通知(现在通知)单聊代表全部消息通知
    • 2: @ 指定用户通知
    • 3: @ 群用户组通知,通知用户组暂未实现,暂不暴露出去
    • 4: @ 群全员通知
    • 5: 消息通知被屏蔽,即不接收消息通知
    since

    5.3.0

    example

    设置会话免打扰示例:

    const options = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    }
    const notificationLevel = RongIMLib.NotificationLevel.NOT_MESSAGE_NOTIFICATION;
    const res = await RongIMLib.setConversationNotificationLevel(options, notificationLevel);
    console.info('设置会话免打扰结果:', res);

    Parameters

    Returns Promise<IAsyncRes<void>>

setConversationNotificationStatus

getConversationNotificationLevel

  • 查询指定会话和频道免打扰

    deprecated

    查询通过 setConversationNotificationLevel 接口设置的指定会话和频道免打扰

    1. Electron 平台,从 5.8.4 版本开始支持 setConversationNotificationLevel 接口。
    since

    5.3.0

    example

    查询指定会话和频道免打扰示例:

    const options = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    }
    const conversation = await RongIMLib.getConversationNotificationLevel(options);
    console.info('查询指定会话和频道免打扰结果:', conversation);

    Parameters

    Returns Promise<IAsyncRes<NotificationLevel | undefined>>

getConversationNotificationStatus

getBlockedConversationList

  • 获取免打扰状态列表

    description

    获取已设置免打扰状态的所有会话,接口仅 Web 端支持

    since

    5.1.1

    example

    获取免打扰状态列表示例:

    const list =  await RongIMLib.getBlockedConversationList();
    console.info('获取免打扰状态列表结果:', list);

    Returns Promise<IAsyncRes<IBaseConversationInfo[]>>

    返回一个 IAsyncRes 类型 Promise,data 为 IBaseConversationInfo 类型数组

setConversationToTop

  • 设置会话是否置顶

    defaultvalue

    isUpdateTime 默认为 true

    example

    设置会话是否置顶示例:

    const isTop = true
    const options = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    }
    const res = await RongIMLib.setConversationToTop(options, isTop);
    console.info('设置会话是否置顶结果:', res);

    Parameters

    • options: IConversationOption

      会话信息

    • isTop: boolean = true

      置顶状态

    • isUpdateTime: boolean = true

      是否更新会话操作时间,默认为更新,仅私有云环境有效

    Returns Promise<IAsyncRes<void>>

getTopConversationList

  • 获取置顶会话列表

    description

    注意:该接口在 Web 平台返回数据中将不包含 latestMessage 字段。

    since

    5.6.0

    example

    获取置顶会话列表示例:

    const res = await RongIMLib.getTopConversationList();
    console.info('获取置顶会话列表数结果:', res);

    Parameters

    • Optional conversationTypes: ConversationType[]

      需要传递 ConversationType 类型数组

    • Optional channelId: string

      不传或传 undefined 时获取全部 channelId 类型的置顶会话

    Returns Promise<IAsyncRes<IAReceivedConversation[]>>

    返回一个 IAsyncRes 类型 Promise,data 为 IAReceivedConversation 类型数组

getUnreadConversationList

  • 获取未读会话列表

    description

    注意:该接口在 Web 平台返回数据中将不包含 latestMessage 字段。

    since

    5.7.0

    example

    获取未读会话列表示例:

    const res = await RongIMLib.getUnreadConversationList();
    console.info('获取未读会话列表结果:', res);

    Parameters

    Returns Promise<IAsyncRes<IAReceivedConversation[]>>

    返回一个 IAsyncRes 类型 Promise,data 为 IAReceivedConversation 类型数组

消息

sendMessage

  • 发送消息

    description

    发送消息的基础接口,可用来发送 IMLib 中的内置类型消息或自定义消息。针对不同的特定消息类型

    example

    发送文本消息示例:

    const content = {content: 'hello world'};
    const message = new RongIMLib.TextMessage(content);
    const conversation = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId'
    }
    const sendRes = await RongIMLib.sendMessage(conversation, message);
    console.info('消息发送结果:', sendRes);

    Parameters

    Returns Promise<IAsyncRes<IAReceivedMessage>>

    返回一个 IAsyncRes 类型 Promise,data 结构为 IAReceivedMessage 类型

sendTextMessage

  • 发送文本消息

    description

    发送文本消息的快捷方式,等同于使用 new TextMessage() 创建消息体后调用 sendMessage() 方法

    example

    发送文本消息示例:

    const messageBody = {content: 'hello world'};
    const conversation = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId'
    }
    const sendRes = await RongIMLib.sendTextMessage(conversation, messageBody);
    console.info('消息发送结果:', sendRes);

    Parameters

    Returns Promise<IAsyncRes<IAReceivedMessage>>

    返回一个 IAsyncRes 类型 Promise,data 结构为 IAReceivedMessage 类型

Const sendFileMessage

  • 发送文件消息

    description

    发送文件消息的快捷方式,等同于使用 new FileMessage() 创建消息体后调用 sendMessage() 方法,支持文件上传,上传成功后自动发送消息

    example

    发送文本消息示例:

    const msgBody = { file }; // file 为待上传文件
    const conversation = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId'
    }
    const sendRes = await RongIMLib.sendFileMessage(conversation, msgBody);
    console.info('消息发送结果:', sendRes);

    Parameters

    Returns Promise<IAsyncRes<IAReceivedMessage>>

    返回一个 IAsyncRes 类型 Promise,data 结构为 IAReceivedMessage 类型

Const sendImageMessage

  • 发送图片消息

    description

    发送图片消息的快捷方式,等同于使用 new ImageMessage() 创建消息体后调用 sendMessage() 方法,支持图片上传,上传成功后自动发送消息

    example

    发送图片消息示例:

    const msgBody = { file }; // file 为待上传图片
    const conversation = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId'
    }
    const sendRes = await RongIMLib.sendImageMessage(conversation, msgBody);
    console.info('消息发送结果:', sendRes);

    Parameters

    Returns Promise<IAsyncRes<IAReceivedMessage>>

    返回一个 IAsyncRes 类型 Promise,data 结构为 IAReceivedMessage 类型

Const sendGIFMessage

  • 发送 GIF 图片消息

    description

    发送 GIF 图片消息的快捷方式,等同于使用 new GIFMessage() 创建消息体后调用 sendMessage() 方法,支持 GIF 图片上传,上传成功后自动发送消息

    example

    发送 GIF 图片消息示例:

    const msgBody = { file }; // file 为待上传 GIF 图片
    const conversation = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId'
    }
    const sendRes = await RongIMLib.sendGIFMessage(conversation, msgBody);
    console.info('消息发送结果:', sendRes);

    Parameters

    Returns Promise<IAsyncRes<IAReceivedMessage>>

    返回一个 IAsyncRes 类型 Promise,data 结构为 IAReceivedMessage 类型

Const sendHQVoiceMessage

  • 发送高清语音消息

    description

    待发送的文件必须为 AAC 音频文件。 发送高清语音消息的快捷方式,等同于使用 new HQVoiceMessage() 创建消息体后调用 sendMessage() 方法,支持高清语音上传,上传成功后自动发送消息

    example

    发送高清语音消息示例:

    const msgBody = { file }; // file 为待上传高清语音
    const conversation = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId'
    }
    const sendRes = await RongIMLib.sendHQVoiceMessage(conversation, msgBody);
    console.info('消息发送结果:', sendRes);

    Parameters

    Returns Promise<IAsyncRes<IAReceivedMessage>>

    返回一个 IAsyncRes 类型 Promise,data 结构为 IAReceivedMessage 类型

Const sendSightMessage

  • 发送小视频消息

    description

    发送的小视频消息必须是 MP4 文件,且音频编码为 AAC,视频编码 H264,否则可能造成 iOS 或 Android 接收后不可播放问题。 发送小视频消息的快捷方式,等同于使用 new SightMessage() 创建消息体后调用 sendMessage() 方法,支持小视频上传,上传成功后自动发送消息

    example

    发送小视频消息示例:

    const msgBody = { file, duration: 10, thumbnail: 'base64' }; // file 为待上传小视频,duration 为小视频时长,thumbnail 为小视频封面 base64
    const conversation = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId'
    }
    const sendRes = await RongIMLib.sendSightMessage(conversation, msgBody);
    console.info('消息发送结果:', sendRes);

    Parameters

    Returns Promise<IAsyncRes<IAReceivedMessage>>

    返回一个 IAsyncRes 类型 Promise,data 结构为 IAReceivedMessage 类型

getHistoryMessages

  • 获取历史消息

    description

    获取历史消息,支持分页加载,可指定时间戳、数量、排序方式等参数进行分页获取。

    1. Count 最大值为 100,超过 100 时返回错误码 34232:开发者接口调用时传入的 count 非法
    2. 如果 SDK < 5.7.4,范围为 [1-20];如果 SDK ≧ 5.7.4,范围为 [1-100]。默认值 20
    • 注意
    1. Electron 获取的是本地数据库
    2. Web 获取的是远端历史消息,Web 端不具备持久化的数据存储能力,无法在本地持久化存储历史消息记录与会话列表,因此需要从融云服务端获取数据。
    3. 请确保已开通单群聊消息云端存储服务,如未开通服务请移步到融云开发者后台的 IM 服务管理模块开启。
    defaultvalue

    options = { timestamp: 0, count: 20, order: 0 }

    example

    获取历史消息示例:

    const conversation = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    }
    const messages = await RongIMLib.getHistoryMessages(conversation);
    console.info('获取历史消息结果:', messages);

    Parameters

    Returns Promise<IAsyncRes<GetHistoryMessageResult>>

    返回一个 IAsyncRes 类型 Promise,data 结构为 GetHistoryMessageResult 类型

getRemoteHistoryMessages

  • 获取远程历史消息

    description

    获取远程历史消息,支持分页加载,可指定时间戳、数量、排序方式等参数进行分页获取。

    1. Count 最大值为 100,超过 100 时返回错误码 34232:开发者接口调用时传入的 count 非法
    2. 如果 SDK < 5.7.4,范围为 [1-20];如果 SDK ≧ 5.7.4,范围为 [1-100]。默认值 20
    • 注意: 需要开启单群聊消息云存储服务后,才可以从远端拉取历史消息,服务请移步到融云开发者后台的 IM 服务管理模块开启。
    defaultvalue

    options = { timestamp: 0, count: 20, order: 0 }

    example

    获取远程历史消息示例:

    const conversation = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    }
    const messages = await RongIMLib.getRemoteHistoryMessages(conversation);
    console.info('获取远程历史消息结果:', messages);

    Parameters

    Returns Promise<IAsyncRes<GetHistoryMessageResult>>

    返回一个 IAsyncRes 类型 Promise,data 结构为 GetHistoryMessageResult 类型

sendReadReceiptMessage

  • sendReadReceiptMessage(targetId: string, messageUId: string, timestamp: number, channelId?: string): Promise<IAsyncRes<void>>
  • 发送单聊已读回执

    description

    发送单聊已读回执,用于标记已读消息

    • 实现已读功能步骤:
    1. 在用户查看了某单聊会话的未读消息后,调用 sendReadReceiptMessage 发送已读回执。
    2. 通过 addEventListener 设置消息回执监听器。
    3. SDK 在收到消息已读回执时派发 READ_RECEIPT_RECEIVED 事件。
    • 注意
    1. 在 Web 平台,SDK 不会记录每个会话和消息的已读状态,您需要在 localStorage 中记录每个会话的已读时间。在渲染消息列表时,根据 localStorage 中时间判断消息是否已读,更新对应的消息界面。
    2. 在 Electron 平台,收到 READ_RECEIPT_RECEIVED 通知时,您需要调用 electronExtension.setMessageStatusToRead 方法更新消息已读状态,并更新对应的消息界面。
    3. 调用 sendReadReceiptMessage 接口不会清除未读数,需单独调用清除未读数接口 clearMessagesUnreadStatus
    example

    单聊消息回执示例:

    const targetId = 'targetId';
    const messageUId = 'BS4O-QEBR-VJM6-9GPP';
    const timestamp = 1632728573423;

    const readReceiptRes = await RongIMLib.sendReadReceiptMessage(targetId, messageUId, timestamp);
    console.info('单聊消息回执:', readReceiptRes)

    Parameters

    • targetId: string

      目标 ID

    • messageUId: string

      消息唯一标识,可在 Message 中获取

    • timestamp: number

      消息的发送时间,可通过 Message 中 sendTime 获取

    • Optional channelId: string

    Returns Promise<IAsyncRes<void>>

sendReadReceiptRequest

  • sendReadReceiptRequest(targetId: string, messageUId: string, channelId?: string): Promise<IAsyncRes<void>>
  • 发送群已读回执请求

    description

    实现群聊中按需获取己方发送消息的阅读状态请求。与群聊已读回执响应接口 sendReadReceiptResponseV2 配套使用。单独调用无法实现群回执能力

    example

    群已读回执请求示例:

    const targetId = 'targetId';
    const messageUId = 'BS4O-QEBR-VJM6-9GPP';
    const readReceiptRes = await RongIMLib.sendReadReceiptRequest(targetId, messageUId);
    console.info('群已读回执请求:', readReceiptRes)

    Parameters

    • targetId: string

      目标 ID

    • messageUId: string
    • Optional channelId: string

    Returns Promise<IAsyncRes<void>>

sendReadReceiptResponse

  • sendReadReceiptResponse(targetId: string, messageUIds: string[], channelId?: string): Promise<IAsyncRes<void>>
  • deprecated

    已废弃,@since 5.1.1。请替换使用 sendReadReceiptResponseV2 方法

    Parameters

    • targetId: string
    • messageUIds: string[]
    • Optional channelId: string

    Returns Promise<IAsyncRes<void>>

sendReadReceiptResponseV2

  • sendReadReceiptResponseV2(targetId: string, messageList?: {}, channelId?: string): Promise<IAsyncRes<void>>
  • 发送群阅读回执响应V2

    description

    实现群聊中按需获取己方发送消息的阅读状态响应。 与群聊已读回执请求接口 sendReadReceiptRequest 配套使用。单独调用无法实现群回执能力

    • 注意

    5.9.4 版本之后,SDK 内部维护了已读回执请求信息,并在历史消息列表里携带已读回执信息:readReceiptInfo, 在 Web 平台和 Electron 平台实现不同之处: Web 和 Electron 平台的区别:

    1. 在 Web 平台,SDK 内部会缓存每个群会话的最新 30 个已读回执信息(以已读回执请求的发送时间为准),缓存有效期为 24H。 在发送消息回执响应时无需传 messageList 字段,SDK 会把该会话下的所有请求组织好然后发送响应。

    2. 在 Electron 平台,用户需先获取历史消息,取出 message.messageDirection = MessageDirection.RECEIVE , readReceiptInfo. isReceiptRequestMessage = true 并且 readReceiptInfo.hasRespond = false 的数据组织成参数 messageList 来发送回执响应。

    since

    5.1.1

    example

    群已读回执响应示例:

    const targetId = 'targetId';
    const messageList = {
    'senderUserId': ['messageUId1', 'messageUId2'],
    }
    const readReceiptRes = await RongIMLib.sendReadReceiptResponseV2(targetId, messageList);
    console.info('群已读回执响应:', readReceiptRes);

    Parameters

    • targetId: string

      群组Id

    • Optional messageList: {}

      要回执的消息列表,结构为: {senderUserId: [messageUId1, messageUId2]}

      • [senderUserId: string]: string[]
    • Optional channelId: string

    Returns Promise<IAsyncRes<void>>

sendSyncReadStatusMessage

  • 多端同步阅读状态

    description

    由于未读消息数存储在本地,服务器不存未读消息数量。当用户多端登录时,需要同步未读消息数以保证多端未读数一致

    example

    多端同步阅读状态示例:

    const conversation = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    }
    const timestamp = 1632728573423; // 阅读消息的 sendTime
    const syncReadStatusRes = await RongIMLib.sendSyncReadStatusMessage(conversation, timestamp);
    console.info('多端同步阅读状态:', syncReadStatusRes);

    Parameters

    • conversation: IConversationOption

      会话信息

    • timestamp: number

      需要同步消息阅读的时间戳,可以在消息体中通过消息的 sendTime 获取

    Returns Promise<IAsyncRes<void>>

recallMessage

  • 撤回消息

    description

    融云对撤回消息的操作者不作限制。 如需避免用户撤回非本人发送的消息,可以提交工单申请打开IMLib SDK 只允许撤回自己发送的消息。从融云服务端进行限制,禁止用户撤回非本人发送的消息。

    example

    撤回消息示例:

    const conversation = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    }
    const options = {
    messageUId: 'messageUId',
    sentTime: 1632728573423,
    }
    const recallRes = await RongIMLib.recallMessage(conversation, options);
    console.info('撤回消息结果:', recallRes);

    Parameters

    Returns Promise<IAsyncRes<IAReceivedMessage>>

    返回一个 IAsyncRes 类型 Promise,data 结构为 IAReceivedMessage 类型

deleteMessages

  • 按消息 UId 删除消息

    description

    根据消息的 ID、时间戳和方向(发送或接收)从服务端删除指定单个会话中的一条或一组消息。

    • 注意
    1. 删除消息仅会删除本端消息,不会删除对端消息。A 与 B 之间的消息,A 删除消息后,B 仍然可以看到消息。如 B 需要无法查看需要调用撤回消息 recallMessage接口。
    2. 仅适用于 App Key 已开通单群聊消息云端存储 的 App。
    3. 服务端默认不会删除对应的离线消息补偿,如需彻底删除消息补偿,请提交工单,申请开通删除服务端历史消息时同时删除多端补偿的离线消息。
    example

    按消息 UId 删除消息示例:

    const conversation = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    };
    const messages = [{
    messageUId: 'BS4O-P5AO-D1O6-9GPP', // 消息 UId
    sentTime: 1632728573423, // 消息发送时间
    messageDirection: RongIMLib.MessageDirection.SEND, // 消息方向
    }];
    const deleteRes = await RongIMLib.deleteMessages(conversation, messages);
    console.info('删除消息结果:', deleteRes);

    Parameters

    Returns Promise<IAsyncRes<void>>

clearHistoryMessages

  • 按时间戳删除消息

    description

    根据时间戳删除指定单个会话中早于(含)指定时间戳的所有消息。

    example

    按时间戳删除消息示例:

    const conversation = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    }
    const timestamp = 1632728573423;
    const clearRes = await RongIMLib.clearHistoryMessages(conversation, timestamp);
    console.info('清除消息结果:', clearRes);

    Parameters

    • conversation: IConversationOption

      会话

    • timestamp: number

      清除时间点, 该时间之前的消息将被清除

    Returns Promise<IAsyncRes<void>>

updateMessageExpansion

  • 更新(添加、替换)消息扩展属性

    description

    消息扩展功能可为消息增加基于 Key/Value 的状态标识。消息的扩展信息可在发送前、后设置或更新,可用于实现消息评论、礼物领取、订单状态变化等业务需求。

    • 注意
    1. 单条消息单次最多可设置 20 个扩展信息 KV 对,总计不可超过 300 个扩展信息 KV 对。
    2. 消息扩展(Key、Value 扩展信息)会被存储。如已开通历史消息云存储功能,从服务端获取的历史消息也会携带已设置的扩展信息。
    3. 仅支持单聊、群聊会话类型,不支持聊天室类型。
    4. 仅当发送消息时指定 canIncludeExpansion 值为 true,才可对消息进行拓展。
    example

    更新(添加、替换)消息扩展属性示例:

    const expansion = { key1: 'value1' };
    // message 为 IAReceivedMessage 类型消息体,此处不做具体示例,可在消息监听或者获取历史消息接口获取需要操作的 message
    const updateRes = await RongIMLib.updateMessageExpansion(expansion, message);
    console.info('更新消息扩展属性结果:', updateRes);

    Parameters

    • expansion: {}

      要更新的消息扩展信息键值对

      • [key: string]: any
    • message: IAReceivedMessage

      要更新的原始消息体

    Returns Promise<IAsyncRes<void>>

removeMessageExpansionForKey

  • 删除扩展存储

    description

    删除消息扩展信息中指定的 Key

    params

    keys 需删除消息扩展的 keys

    params

    message 原始消息体

    example

    删除扩展存储示例:

    const keys = ['key1'];
    // message 为 IAReceivedMessage 类型消息体,此处不做具体示例,可在消息监听或者获取历史消息接口获取需要操作的 message
    const removeRes = await RongIMLib.removeMessageExpansionForKey(keys, message);
    console.info('删除扩展存储结果:', removeRes);

    Parameters

    Returns Promise<IAsyncRes<void>>

sendTypingStatusMessage

  • 发送输入状态消息

    description

    发送输入状态消息,用于展示对方正在输入的状态

    example

    发送输入状态消息示例:

    const conversation = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    }
    const typingContentType = RongIMLib.MessageType.TEXT;
    const typingRes = await RongIMLib.sendTypingStatusMessage(conversation, typingContentType);
    console.info('发送typing消息结果:', typingRes);

    Parameters

    • conversation: IConversationOption

      会话信息

    • typingContentType: string

      输入状态消息类型

    Returns Promise<IAsyncRes<IAReceivedMessage>>

    返回一个 IAsyncRes 类型 Promise,data 结构为 IAReceivedMessage 类型

getMessageReader

  • 获取群已读列表

    example
    const messageUId = 'messageUId';
    const targetId = 'targetId';
    const getReaderRes = await RongIMLib.getMessageReader(targetId, messageUId);
    console.info('获取群已读列表结果:', getReaderRes);

    Parameters

    • targetId: string

      群 ID

    • messageUId: string

      消息UID

    • Optional channelId: string

    Returns Promise<IAsyncRes<IMessageReaderResponse>>

    返回一个 IAsyncRes 类型 Promise,data 结构为 IMessageReaderResponse 类型

registerMessageType

  • registerMessageType<T>(messageType: string, isPersited: boolean, isCounted: boolean, searchProps?: string[], isStatusMessage?: boolean): new (content: T) => BaseMessage<T>
  • 注册自定义消息

    description

    注册自定义消息,用于定义自定义消息的类型,会影响消息的发送和接收

    • 注意
    1. 注册自定义消息代码必须在发送、接收该自定义消息之前
    2. 推荐将所有注册自定义消息代码放在 init 方法之后, connect 方法之前
    3. 注册的消息类型名, 必须多端一致, 否则消息无法互通
    4. 请勿使用 RC: 开头的类型名,以免和 SDK 默认的消息名称冲突,自定义消息的消息类型名如和 SDK 默认的消息类型名相同以 SDK 默认的消息定义名为准
    5. 需要再 connect 之前调用防止手消息行为异常
    example
    const messageType = 'CustomMessage';
    const isPersited = true;
    const isCounted = true;
    const searchProps = ['content']; // 搜索字段
    const isStatusMsg = false;
    const CustomMessage = RongIMLib.registerMessageType(messageType, isPersited, isCounted, searchProps, isStatusMsg);

    Type parameters

    • T

    Parameters

    • messageType: string

      消息类型

    • isPersited: boolean

      是否存储

    • isCounted: boolean

      是否计数

    • Optional searchProps: string[]

      可搜索的属性,web 端无需设置,搜索字段值设置为数字时取值范围为 (-Math.pow(2, 64), Math.pow(2, 64)) 且为整数

    • Optional isStatusMessage: boolean

      是否状态消息,状态消息不计数,不存储,接收方在线时才能收到

    Returns new (content: T) => BaseMessage<T>

    返回一个 BaseMessage 类型的构造函数

getFirstUnreadMessage

  • 获取第一条未读消息

    description

    获取指定会话中的第一条未读消息,仅支持 Electron 平台

    example

    获取第一条未读消息示例:

    const conversation = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    }
    const firstUnreadRes = await RongIMLib.getFirstUnreadMessage(conversation);
    console.info('获取第一条未读消息结果:', firstUnreadRes);

    Parameters

    Returns Promise<IAsyncRes<IAReceivedMessage | null>>

    返回一个 IAsyncRes 类型 Promise,data 结构为 IAReceivedMessage 类型

getFirstUnreadMessageInfo

  • 获取第一条未读消息信息

    since

    5.9.0

    description

    获取指定会话中的第一条未读消息信息

    • 注意
    1. 当没有未读消息时,返回的 data 为 null
    2. 当第一条未读消息被撤回时,此信息不会更新
    example

    获取第一条未读消息信息示例:

    const conversation = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    }
    const firstUnreadMessageInfoRes = await RongIMLib.getFirstUnreadMessageInfo(conversation);
    console.info('获取第一条未读消息信息结果:', firstUnreadMessageInfoRes);

    Parameters

    Returns Promise<IAsyncRes<IFirstUnreadMessageInfo | null>>

    返回一个 IAsyncRes 类型 Promise,data 结构为 IFirstUnreadMessageInfo 类型

insertMessage

getMessage

  • 获取消息

    description

    获取本地消息, 通过本地消息 ID 或 messageUId 获取消息, 仅支持 Electron 平台

    example

    获取消息示例:

    const messageUId = 'BS4O-P5AO-D1O6-9GPP';
    const getMessageRes = await RongIMLib.getMessage(messageUId);
    console.info('获取消息结果:', getMessageRes);

    Parameters

    • messageId: string | number

      本地消息 ID 或 messageUId

    Returns Promise<IAsyncRes<IAReceivedMessage>>

    返回一个 IAsyncRes 类型 Promise,data 结构为 IAReceivedMessage 类型

getUnreadMentionedMessages

  • 获取会话下所有未读的 @ 消息

    example

    获取会话下所有未读的 @ 消息示例:

    const conversation = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    }
    const getUnreadMentionedRes = await RongIMLib.getUnreadMentionedMessages(conversation);
    console.info('获取会话下所有未读的 @ 消息结果:', getUnreadMentionedRes);

    Parameters

    Returns IAsyncRes<IAReceivedMessage[]>

    返回一个 IAsyncRes 类型 Promise,data 结构为 {@link IAReceivedMessage[]} 类型

searchMessages

deleteLocalMessagesByTimestamp

clearMessages

searchConversationByContent

clearUnreadCountByTimestamp

  • 清除时间戳前的未读数

    description

    清除时间戳前的未读数,仅支持 Electron 平台。

    example

    清除时间戳前的未读数示例:

    const conversation = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    }
    const timestamp = 1626955200000;
    const clearRes = await RongIMLib.clearUnreadCountByTimestamp(conversation, timestamp);
    console.info('清除时间戳前的未读数结果:', clearRes);

    Parameters

    Returns Promise<IAsyncRes<void>>

setMessageReceivedStatus

  • setMessageReceivedStatus(messageId: number, receivedStatus: number): Promise<IAsyncRes<void>>

MessageType

MessageType: { TEXT: string; VOICE: string; HQ_VOICE: string; IMAGE: string; GIF: string; RICH_CONTENT: string; LOCATION: string; FILE: string; SIGHT: string; COMBINE: string; COMBINE_V2: string; CHRM_KV_NOTIFY: string; LOG_COMMAND: string; EXPANSION_NOTIFY: string; REFERENCE: string; RECALL_MESSAGE_TYPE: string } = ...

消息类型

Type declaration

  • TEXT: string
  • VOICE: string
  • HQ_VOICE: string
  • IMAGE: string
  • GIF: string
  • RICH_CONTENT: string
  • LOCATION: string
  • FILE: string
  • SIGHT: string
  • COMBINE: string
  • COMBINE_V2: string
  • CHRM_KV_NOTIFY: string
  • LOG_COMMAND: string
  • EXPANSION_NOTIFY: string
  • REFERENCE: string
  • RECALL_MESSAGE_TYPE: string

聊天室

joinChatRoom

  • joinChatRoom(targetId: string, options: { count: number; extra?: string }): Promise<IAsyncRes<void>>
  • 加入聊天室

    description

    接口会创建并加入聊天室。如果聊天室已存在,则直接加入聊天室

    deprecated

    从 @since 5.8.3 开始废弃该方法,请使用 joinExistChatRoom 代替

    Parameters

    • targetId: string

      聊天室 ID

    • options: { count: number; extra?: string }

      加入聊天室配置参数

      • count: number

        拉取消息数

      • Optional extra?: string

        扩展信息

        since

        5.10.3

    Returns Promise<IAsyncRes<void>>

joinExistChatRoom

  • 加入已存在的聊天室

    description

    聊天室已存在,在获取 chatRoomId 后可以调用 joinExistChatRoom 加入聊天室。该方法只能加入已存在的聊天室。

    • 注意
    1. Electron 平台从 5.7.0 开始提供该接口
    2. 从 5.8.3 开始,成功回调的 data 数据中返回聊天室信息和禁言状态,详见 IChatroomJoinResponse
    3. 断网重连场景下,SDK 重新加入聊天室成功后,会按照加入聊天室时传入的 count 值拉取固定数量的消息。拉取的消息有可能在本地已存在,App 可能需要进行排重后再显示
    defaultvalue

    options.count 为 10

    example

    加入已存在的聊天室示例:

    const chatRoomId = 'chatroomId';
    const options = { count: 10 };
    const res = await RongIMLib.joinExistChatRoom(chatRoomId, options);
    console.log('加入已存在的聊天室结果:', res);

    Parameters

    • targetId: string

      聊天室 ID

    • options: { count: number; extra?: string }

      加入聊天室配置参数, count 为进入聊天室时获取历史消息的数量,数量范围:1-50。如果传 -1,表示不获取任何历史消息。如果传 0,表示使用 SDK 默认设置(默认为获取 10 条)

      • count: number

        拉取消息数

      • Optional extra?: string

        扩展信息

        since

        5.10.3

    Returns Promise<IAsyncRes<IChatroomJoinResponse>>

    返回一个 IAsyncRes 类型 Promise,data 为 IChatroomJoinResponse 类型

quitChatRoom

  • quitChatRoom(targetId: string): Promise<IAsyncRes<void>>
  • 退出聊天室

    description

    客户端用户可主动退出聊天室,退出后不再接收聊天室消息

    example

    退出聊天室示例:

    const chatRoomId = 'chatroomId';
    const res = await RongIMLib.quitChatRoom(chatRoomId);
    console.log('退出聊天室结果:', res);

    Parameters

    • targetId: string

      聊天室 ID

    Returns Promise<IAsyncRes<void>>

getChatRoomInfo

  • getChatRoomInfo(targetId: string, options?: { count?: number; order?: 0 | 1 | 2 }): Promise<IAsyncRes<IChatroomInfo>>
  • 查询聊天室房间信息

    description

    获取聊天室的信息,返回聊天室成员总数和指定数量(最多 20 个)的聊天室成员的列表,包括该成员的用户 ID 以及加入聊天室的时间

    • 注意
    1. count 或 order 有一个为 0 时,只返回成员总数,不返回成员列表信息, order 人员排序方式,1 为正序,2 为倒序,默认为 0 不返回
    2. 单个设备每秒钟支持调用一次,每分钟单个设备最多调用 20 次
    example

    查询聊天室房间信息示例:

    const chatRoomId = 'chatroomId';
    const options = { count: 10, order: 1 };
    const res = await RongIMLib.getChatRoomInfo(chatRoomId, options);
    console.log('查询聊天室房间信息结果:', res);

    Parameters

    • targetId: string

      聊天室 ID

    • Optional options: { count?: number; order?: 0 | 1 | 2 }

      查询聊天室信息配置参数

      • Optional count?: number

        获取聊天室的人数,传值范围:0-20,默认为 0

      • Optional order?: 0 | 1 | 2

        聊天室的人员排序,默认为 0 不返回

        • 1: 升序
        • 2: 降序

    Returns Promise<IAsyncRes<IChatroomInfo>>

    返回一个 IAsyncRes 类型 Promise,data 为 IChatroomInfo 类型

setChatRoomEntry

  • 设置单个属性

    description

    设置聊天室属性,支持设置 Key-Value 类型的属性信息

    • 功能局限性:
    1. 聊天室销毁后,聊天室中的自定义属性同时销毁。
    2. 每个聊天室中,最多允许设置 100 个属性信息,以 Key-Value 的方式进行存储。
    3. 客户端 SDK 未针对聊天室属性 KV 的操作频率进行限制。建议每个聊天室,每秒钟操作 Key-Value 频率保持在 100 次及以下(一秒内单次操作 100 个 KV 等同于操作 100 次)。
    • 注意
    1. 使用该接口需要开通 聊天室属性自定义设置 功能,您可以前往控制台的免费基础功能页面开启服务。
    2. 仅聊天室中不存在此属性或属性设置者为己方时可设置成功
    example

    设置单个属性示例:

    const chatRoomId = 'chatroomId';
    const options = {
    key: 'key',
    value: 'value',
    };
    const res = await RongIMLib.setChatRoomEntry(chatRoomId, options);
    console.log('设置单个属性结果:', res);

    Parameters

    Returns Promise<IAsyncRes<void>>

setChatRoomEntries

  • 批量设置属性

    description

    批量设置聊天室属性

    • 功能局限性:

    • 聊天室销毁后,聊天室中的自定义属性同时销毁。

    • 每个聊天室中,最多允许设置 100 个属性信息,以 Key-Value 的方式进行存储。

    • 客户端 SDK 未针对聊天室属性 KV 的操作频率进行限制。建议每个聊天室,每秒钟操作 Key-Value 频率保持在 100 次及以下(一秒内单次操作 100 个 KV 等同于操作 100 次)。

    • 注意

    1. 使用该接口需要开通 聊天室属性自定义设置 功能,您可以前往控制台的免费基础功能页面开启服务。
    2. 仅聊天室中不存在此属性或属性设置者为己方时可设置成功
    example

    批量设置属性示例:

    const chatRoomId = 'chatroomId';
    const options = { entries: [{ key: 'key', value: 'value' }] };
    const res = await RongIMLib.setChatRoomEntries(chatRoomId, options);
    console.log('批量设置属性结果:', res);

    Parameters

    • targetId: string

      聊天室 ID

    • options: IChatroomEntries

      设置聊天室属性配置参数 类型为 IChatroomEntries @since 5.3.4 版本开始,该接口同时支持通过 isForce 属性强制设置多个属性值。强制设置可直接覆盖他人创建的属性值。

    Returns Promise<IAsyncRes<void>>

forceSetChatRoomEntry

  • 强制设置单个属性

    description

    强制设置单个聊天室属性。可用于修改他人创建的属性值,以 key = value 的形式存储。当 key 不存在时,代表增加属性; 当 key 已经存在时,代表更新属性的值。使用强制设置可修改他人创建的属性值

    example

    强制设置单个属性示例:

    const chatRoomId = 'chatroomId';
    const options = {
    key: 'key',
    value: 'value',
    };
    const res = await RongIMLib.forceSetChatRoomEntry(chatRoomId, options);
    console.log('强制设置单个属性结果:', res);

    Parameters

    Returns Promise<IAsyncRes<void>>

removeChatRoomEntry

  • 删除单个属性

    description

    删除聊天室自定义属性。只可删除当前用户所创建的属性

    example

    删除单个属性示例:

    const targetId = 'chatroomId';
    const options = {
    key: 'key',
    };
    const res = await RongIMLib.removeChatRoomEntry(targetId, options);
    console.log('删除单个属性结果:', res);

    Parameters

    Returns Promise<IAsyncRes<void>>

removeChatRoomEntries

  • removeChatRoomEntries(targetId: string, options: { entries: string[]; notificationExtra?: string }): Promise<IAsyncRes<void>>
  • 批量删除聊天室属性

    description

    删除聊天室自定义属性。只可删除当前用户所创建的属性

    example

    批量删除聊天室属性示例:

    const targetId = 'chatroomId';
    const options = {
    entries: ['key'],
    };
    const res = await RongIMLib.removeChatRoomEntries(targetId, options);
    console.log('批量删除聊天室属性结果:', res);

    Parameters

    • targetId: string

      聊天室 ID

    • options: { entries: string[]; notificationExtra?: string }

      删除聊天室属性配置参数

      • entries: string[]
      • Optional notificationExtra?: string

    Returns Promise<IAsyncRes<void>>

forceRemoveChatRoomEntry

  • 强制删除

    description

    强制删除聊天室自定义属性。可删除他人所创建的属性

    example

    强制删除示例:

    const targetId = 'chatroomId';
    const options = {
    key: 'key',
    };
    const res = await RongIMLib.forceRemoveChatRoomEntry(targetId, options);
    console.log('强制删除结果:', res);

    Parameters

    Returns Promise<IAsyncRes<void>>

getChatRoomEntry

  • getChatRoomEntry(targetId: string, key: string): Promise<IAsyncRes<string | number | boolean>>
  • 获取单个属性

    description

    获取单个聊天室属性

    example

    获取单个属性示例:

    const targetId = 'chatroomId';
    const key = 'key';
    const res = await RongIMLib.getChatRoomEntry(targetId, key);
    console.log('获取单个属性结果:', res);

    Parameters

    • targetId: string

      聊天室 ID

    • key: string

      属性名称, 支持英文字母、数字、+、=、-、_ 的组合方式, 最大长度 128 字符

    Returns Promise<IAsyncRes<string | number | boolean>>

getAllChatRoomEntries

  • getAllChatRoomEntries(targetId: string): Promise<IAsyncRes<{}>>
  • 获取所有属性

    description

    获取聊天室所有属性

    example

    获取所有属性示例:

    const targetId = 'chatroomId';
    const res = await RongIMLib.getAllChatRoomEntries(targetId);
    console.log('获取所有属性结果:', res);

    Parameters

    • targetId: string

      聊天室 ID

    Returns Promise<IAsyncRes<{}>>

    返回一个 IAsyncRes 类型 Promise,data 为一个对象,包含聊天室所有属性,格式为 { [key: string]: string | number | boolean }

getChatroomHistoryMessages

  • 获取聊天室的历史消息

    description

    获取聊天室的历史消息接口要求开通聊天室消息云端存储服务。使用前请确认已开通服务。开通后聊天室历史消息保存在云端,默认保存 2 个月

    example

    获取聊天室的历史消息示例:

    const chatRoomId = 'chatroomId';
    const options = {
    count: 10,
    order: 1,
    timestamp: 0,
    };
    const res = await RongIMLib.getChatroomHistoryMessages(chatRoomId, options);
    console.log('获取聊天室的历史消息结果:', res);

    Parameters

    Returns Promise<IAsyncRes<GetHistoryMessageResult>>

    返回一个 IAsyncRes 类型 Promise,data 为 GetHistoryMessageResult 类型

bindRTCRoomForChatroom

  • 绑定音视频房间

    description

    聊天室与音视频房间绑定成功后,只要音视频房间仍存在,则阻止聊天室自动销毁

    • 适用场景: 聊天室具有自动销毁机制。在使用融云 RTC 业务的 App 中,可能配合使用 IM SDK 的聊天室业务实现直播聊天、弹幕、属性记录等功能。 这种情况下,可以考虑将聊天室与音视频房间绑定,确保聊天室不会在语聊、直播结束前销毁,以免丢失关键数据。
    since

    5.2.1

    example

    绑定音视频房间示例:

    const option = {
    chatRoomId: 'chatroomId',
    rtcRoomId: 'rtcRoomId',
    };
    const res = await RongIMLib.bindRTCRoomForChatroom(option);
    console.log('绑定音视频房间结果:', res);

    Parameters

    Returns Promise<IAsyncRes<void>>

超级群

getUltraGroupList

  • 获取超级群会话列表

    description

    获取超级群会话列表,不传则获取全部超级群会话列表,该列表不包含未产生任何消息的会话。

    since

    5.2.0 仅 Web 端 IMLib 支持超级群。Electron 解决方案暂不适用于超级群业务。

    defaultvalue

    options 默认值为 {}

    example

    获取超级群会话列表示例:

    const res = await RongIMLib.getUltraGroupList();
    console.log('获取超级群会话列表结果:', res);

    Parameters

    Returns Promise<IAsyncRes<IUltraGroupConversation[]>>

    返回一个 IAsyncRes 类型 Promise,data 为超级群会话列表 {@link IUltraGroupConversation[]},code 接口返回状态码

getBlockUltraGroupList

  • 获取当前登录用户免打扰超级群会话列表

    description

    获取当前登录用户免打扰超级群会话列表

    since

    5.2.0 仅 Web 端 IMLib 支持超级群。Electron 解决方案暂不适用于超级群业务。

    example

    获取当前登录用户免打扰超级群会话列表示例:

    const res = await RongIMLib.getBlockUltraGroupList();
    console.log('获取当前登录用户免打扰超级群会话列表结果:', res);

    Returns Promise<IAsyncRes<IBaseConversationInfo[]>>

    返回一个 IAsyncRes 类型 Promise,data 为超级群会话列表 {@link IUltraGroupConversation[]},code 接口返回状态码

sendUltraGroupTypingStatus

  • 发送输入状态

    description

    发送输入状态,用于通知服务端正在输入中

    since

    5.2.0 仅 Web 端 IMLib 支持超级群。Electron 解决方案暂不适用于超级群业务。

    example

    发送输入状态示例:

    const options = {
    conversationType: RongIMLib.ConversationType.ULTRA_GROUP,
    targetId: 'targetId',
    channelId: 'channelId',
    };
    const res = await RongIMLib.sendUltraGroupTypingStatus(options);
    console.log('发送输入状态结果:', res);

    Parameters

    Returns Promise<IAsyncRes<void>>

    返回一个 IAsyncRes 类型 Promise,code 接口返回状态码

getUltraGroupMessageListByMessageUId

  • 从服务端获取特定批量消息

    description

    根据消息的 Uid 从服务端获取特定批量消息

    since

    5.2.0 仅 Web 端 IMLib 支持超级群。Electron 解决方案暂不适用于超级群业务。

    example

    从服务端获取特定批量消息示例:

    const options = {
    conversationType: RongIMLib.ConversationType.ULTRA_GROUP,
    targetId: 'targetId',
    channelId: 'channelId',
    };
    // sendTime 为消息的发送时间,此处示例为假数据
    const messages = [{ messageUId: 'messageUId1', sendTime: 1626864000000, }];
    const res = await RongIMLib.getUltraGroupMessageListByMessageUId(options, messages);
    console.log('从服务端获取特定批量消息结果:', res);

    Parameters

    Returns Promise<IAsyncRes<{}>>

    返回一个 IAsyncRes 类型 Promise,data 为消息列表,code 接口返回状态码 从 SDK 版本 @since 5.7.0 开始,该接口的返回数据类型由 IReceivedMessage 变更为 IAReceivedMessage

updateExpansionForUltraGroupMessage

  • 设置、更新消息扩展信息

    description

    设置、更新消息扩展信息,用于超级群消息扩展信息的设置、更新,消息扩展信息

    • 适用场景:原始消息增加状态标识的需求,都可使用消息扩展
    1. 消息评论需求,可通过设置原始消息扩展信息的方式添加评论信息。
    2. 礼物领取、订单状态变化需求,通过此功能改变消息显示状态。 例如:向用户发送礼物,默认为未领取状态,用户点击后可设置消息扩展为已领取状态
    • 注意
    1. 每次设置消息扩展将会产生内置通知消息,频繁设置扩展会产生大量消息
    2. 仅当发送消息时指定 canIncludeExpansion 值为 true,才可对消息进行扩展
    since

    5.2.0 仅 Web 端 IMLib 支持超级群。Electron 解决方案暂不适用于超级群业务。

    example

    设置、更新消息扩展信息示例:

    const expansion = { key1: 'value1' };
    const message = {} // 需要设置的消息,类型为 IAReceivedMessage
    const res = await RongIMLib.updateExpansionForUltraGroupMessage(expansion, message);
    console.log('设置、更新消息扩展信息结果:', res);

    Parameters

    • expansion: {}

      消息扩展信息,类型是 Object。Key 支持大小写英文字母、数字、 特殊字符+ = - _ 的组合方式,不支持汉字。最大 32 个字符。
      (SDK < 5.3.0)Value 最大 64 个字符
      (SDK ≧ 5.3.0)Value 最大 4096 个字符

      • [key: string]: any
    • message: IAReceivedMessage

      接收到的消息,类型是 IAReceivedMessage

    Returns Promise<IAsyncRes<void>>

    返回一个 IAsyncRes 类型 Promise,code 接口返回状态码

removeExpansionForUltraGroupMessage

  • 删除消息扩展

    description

    删除消息扩展,用于超级群消息扩展信息的删除,消息扩展信息

    since

    5.2.0 仅 Web 端 IMLib 支持超级群。Electron 解决方案暂不适用于超级群业务。

    example

    删除消息扩展示例:

    const expansion = ['key1'];
    // message 需要删除扩展的消息,类型为 IAReceivedMessage,此处示例伪代码
    const res = await RongIMLib.removeExpansionForUltraGroupMessage(expansion, message);
    console.log('删除消息扩展结果:', res);

    Parameters

    • expansion: string[]

      消息扩展信息的 key 数组,类型是 Array。Key 支持大小写英文字母、数字、特殊字符+ = - _ 的组合方式,不支持汉字。最大 32 个字符

    • message: IAReceivedMessage

      接收到的消息,类型是 IAReceivedMessage

    Returns Promise<IAsyncRes<void>>

    返回一个 IAsyncRes 类型 Promise,code 接口返回状态码

removeAllExpansionForUltraGroupMessage

  • 删除指定消息上的所有扩展

    description

    删除指定消息上的所有扩展,用于超级群消息扩展信息的删除,消息扩展信息

    since

    5.2.0 仅 Web 端 IMLib 支持超级群。Electron 解决方案暂不适用于超级群业务。

    example

    删除指定消息上的所有扩展示例:

    // message 需要删除扩展的消息,类型为 IAReceivedMessage,此处示例伪代码
    const res = await RongIMLib.removeAllExpansionForUltraGroupMessage(message);
    console.log('删除指定消息上的所有扩展结果:', res);

    Parameters

    Returns Promise<IAsyncRes<void>>

    返回一个 IAsyncRes 类型 Promise,code 接口返回状态码

modifyMessage

  • 修改消息

    description

    用户在成功发送超级群消息后,可以主动修改已发送消息的消息内容 消息被修改后,IAReceivedMessage 对象的 isModifyMessage 属性会被更新为 true

    • 注意
    1. 消息类型无法修改。如果改前为文本消息,则传入的新消息内容必须为 ITextMessageBody 类型
    2. 无法修改他人发送的消息。
    since

    5.2.0 仅 Web 端 IMLib 支持超级群。Electron 解决方案暂不适用于超级群业务。

    example

    修改消息示例:

    const content = { text: '修改后的消息内容' };
    // message 需要修改的消息,类型为 IAReceivedMessage,此处示例伪代码
    const res = await RongIMLib.modifyMessage(content, message);
    console.log('修改消息结果:', res);

    Parameters

    Returns Promise<IAsyncRes<void>>

    返回一个 IAsyncRes 类型 Promise,code 接口返回状态码

getUltraGroupUnreadMentionedCountByTargetId

  • getUltraGroupUnreadMentionedCountByTargetId(targetId: string, notificationLevels?: NotificationLevel[]): Promise<IAsyncRes<number>>
  • 获取指定会话的未读 @ 消息数

    description

    获取当前用户在指定超级群会话中的未读 @ 消息数

    since

    5.5.1 仅 Web 端 IMLib 支持超级群。Electron 解决方案暂不适用于超级群业务。

    example

    获取指定会话的未读 @ 消息数示例:

    const targetId = 'targetId';
    const res = await RongIMLib.getUltraGroupUnreadMentionedCountByTargetId(targetId);
    console.log('获取指定会话的未读 @ 消息数结果:', res);

    Parameters

    • targetId: string

      超级群 Id

    • Optional notificationLevels: NotificationLevel[]

      免打扰级别,不传或传空数组则获取全部级别,类型为 NotificationLevel 数组

    Returns Promise<IAsyncRes<number>>

    返回一个 IAsyncRes 类型 Promise,data 为未读 @ 消息数,code 接口返回状态码

getUltraGroupDefaultNotificationLevel

  • 查询指定超级群或频道的默认免打扰级别

    since

    5.2.0 仅 Web 端 IMLib 支持超级群。Electron 解决方案暂不适用于超级群业务。

    example

    查询指定超级群或频道的默认免打扰级别示例:

    const options = {
    targetId: 'targetId',
    channelId: 'channelId',
    };
    const res = await RongIMLib.getUltraGroupDefaultNotificationLevel(options);
    console.log('查询指定超级群或频道的默认免打扰级别结果:', res);

    Parameters

    Returns Promise<IAsyncRes<NotificationLevel>>

    返回一个 IAsyncRes 类型 Promise,data 为默认免打扰级别,code 接口返回状态码

setUltraGroupDefaultNotificationLevel

  • 设置指定超级群或频道的默认免打扰级别

    description

    为指定的超级群设置的默认免打扰逻辑,自动适用于群下的所有频道。如果针对频道另行设置了默认免打扰逻辑,则以该频道的默认设置为准

    since

    5.2.0 仅 Web 端 IMLib 支持超级群。Electron 解决方案暂不适用于超级群业务

    example

    设置指定超级群或频道的默认免打扰级别示例:

    const options = {
    targetId: 'targetId',
    channelId: 'channelId',
    };
    const notificationLevel = RongIMLib.NotificationLevel.NOT_MESSAGE_NOTIFICATION;
    const res = await RongIMLib.setUltraGroupDefaultNotificationLevel(options, notificationLevel);
    console.log('设置指定超级群或频道的默认免打扰级别结果:', res);

    Parameters

    • options: IUltraGroupOption

      设置超级群或频道的默认免打扰级别参数,包含会话类型、目标 Id、频道 Id,类型为 IUltraGroupOption

      • 设置超级群默认通知配置 options: { targetId: 'xxx' }, channelId 不传或传 ''
      • 设置超级群指定频道默认通知配置 options: { targetId: 'xxx', channelId: 'xxx' }
    • notificationLevel: NotificationLevel

      免打扰级别 @since 5.3.0 以后 notificationLevel 类型为 NotificationLevel

    Returns Promise<IAsyncRes<void>>

    返回一个 IAsyncRes 类型 Promise,code 接口返回状态码

getUltraGroupUnreadCountByTargetId

  • 获取指定会话的未读消息数

    description

    获取当前用户在指定超级群会话中的未读消息数

    since

    5.5.1 仅 Web 端 IMLib 支持超级群。Electron 解决方案暂不适用于超级群业务。

    example

    获取指定会话的未读消息数示例:

    const targetId = 'targetId';
    const res = await RongIMLib.getUltraGroupUnreadCountByTargetId(targetId);
    console.log('获取指定会话的未读消息数结果:', res);

    Parameters

    • targetId: string

      超级群 Id

    • Optional notificationLevels: NotificationLevel[]

      免打扰级别,不传或传空数组则获取全部级别,类型为 NotificationLevel 数组

    Returns Promise<IAsyncRes<number>>

    返回一个 IAsyncRes 类型 Promise,data 为未读消息数,code 接口返回状态码

getAllUltraGroupUnreadCount

  • getAllUltraGroupUnreadCount(): Promise<IAsyncRes<number>>
  • 超级群类型所有未读数

    since

    5.2.0 仅 Web 端 IMLib 支持超级群。Electron 解决方案暂不适用于超级群业务。

    example

    超级群类型所有未读数示例:

    const res = await RongIMLib.getAllUltraGroupUnreadCount();
    console.log('超级群类型所有未读数结果:', res);

    Returns Promise<IAsyncRes<number>>

    返回一个 IAsyncRes 类型 Promise,data 为未读数,code 接口返回状态码

getAllUltraGroupUnreadMentionedCount

  • getAllUltraGroupUnreadMentionedCount(): Promise<IAsyncRes<number>>
  • 获取所有会话的未读 @ 消息数

    description

    获取当前用户加入的所有超级群会话中的未读 @ 消息数的总和

    since

    5.2.0 仅 Web 端 IMLib 支持超级群。Electron 解决方案暂不适用于超级群业务。

    example

    获取所有会话的未读 @ 消息数示例:

    const res = await RongIMLib.getAllUltraGroupUnreadMentionedCount();
    console.log('获取所有会话的未读 @ 消息数结果:', res);

    Returns Promise<IAsyncRes<number>>

    返回一个 IAsyncRes 类型 Promise,data 为未读 @ 消息数,code 接口返回状态码

getUltraGroupUnreadMentionedMessages

  • 超级群获取指定会话未读 @ 消息列表

    description

    从远端获取指定超级群频道中的未读 @ 消息的摘要数据。最多可获取 50 条(count 取值范围为 [1-50])

    • 注意:功能依赖融云服务端保存的超级群会话「未读 @ 消息摘要」数据。「@所有人」消息的摘要数据固定存储 7 天(不支持调整)。其他类型 @ 消息的摘要数据与超级群历史消息存储时长一致。
    since

    5.5.2 仅 Web 端 IMLib 支持超级群。Electron 解决方案暂不适用于超级群业务。

    example

    获取指定会话未读 @ 消息列表示例:

    const options = {
    targetId: 'targetId',
    channelId: 'channelId',
    sentTime: 0,
    count: 10,
    };
    const res = await RongIMLib.getUltraGroupUnreadMentionedMessages(options);
    console.log('获取指定会话未读 @ 消息列表结果:', res);

    Parameters

    Returns Promise<IAsyncRes<IUltraUnreadMsg[]>>

    返回一个 IAsyncRes 类型 Promise,data 为未读 @ 消息列表,code 接口返回状态码

getUltraGroupFirstUnreadMessageTimestamp

  • 获取指定会话的第一条未读消息的时间戳

    description

    获取当前用户在指定超级群会话或指定频道的第一条未读消息的时间戳

    since

    5.5.2 仅 Web 端 IMLib 支持超级群。Electron 解决方案暂不适用于超级群业务。

    example

    获取指定会话第一条未读消息时间戳示例:

    const conversation = {
    targetId: 'targetId',
    channelId: 'channelId',
    };
    const res = await RongIMLib.getUltraGroupFirstUnreadMessageTimestamp(conversation);
    console.log('获取指定会话第一条未读消息时间戳结果:', res);

    Parameters

    Returns Promise<IAsyncRes<IUltraUnreadMsg>>

    返回一个 IAsyncRes 类型 Promise,data 为指定会话第一条未读消息时间戳,code 接口返回状态码

getUltraGroupUnreadInfoList

  • 批量获取超级群会话信息

    description

    根据传入要查询的会话 id,获取该会话下所有频道的 IUltraGroupUnreadInfo 信息

    since

    5.7.10

    example

    批量获取超级群会话信息示例:

    const targetIds = ['targetId1', 'targetId2'];
    const res = await RongIMLib.getUltraGroupUnreadInfoList(targetIds);
    console.log('批量获取超级群会话信息结果:', res);

    Parameters

    • targetIds: string[]

      超级群 Id 数组,数组长度限制 [1-20] 个

    Returns Promise<IAsyncRes<IUltraGroupUnreadInfo[]>>

    返回一个 IAsyncRes 类型 Promise,data 为超级群会话信息列表,code 接口返回状态码

会话未读数

getTotalUnreadCount

  • 获取当前所有会话的消息未读数

    description
    1. 清除浏览器缓存会导致会话未读数不准确
    2. 会话消息未读数存储在 WebStorage 中, 若浏览器不支持或禁用 WebStorage,未读消息数将不会保存,浏览器页面刷新未读消息数将不会存在
    3. 其他端删除会话可能会导致会话未读数不准确
    defaultvalues

    includeMuted: false

    example

    获取当前所有会话的消息未读数示例:

    const totalUnreadCount = await RongIMLib.getTotalUnreadCount();
    console.info('获取当前所有会话的消息未读数结果:', totalUnreadCount);

    Parameters

    • Optional includeMuted: boolean

      是否包含免打扰会话

    • Optional conversationTypes: ConversationType[]

      要获取未读数的会话类型,若为空,则默认获取单聊、群聊及系统消息未读数

    Returns Promise<IAsyncRes<number>>

    返回一个 IAsyncRes 类型 Promise,data 中返回会话未读数

getTotalUnreadCountByLevels

  • 获取会话指定免打扰级别的未读数

    description

    查找免打扰配置符合传入的免打扰级别的会话,返回所有会话中未读消息的总数

    • 注意
    1. 聊天室会话类型不存储未读数,故不支持获取聊天室会话的未读数
    since

    5.5.1 暂不支持 Electron 平台

    example

    获取会话指定免打扰级别的未读数示例:

    const conversationTypes = [RongIMLib.ConversationType.PRIVATE];
    const levels = [RongIMLib.NotificationLevel.ALL_MESSAGE];
    const totalUnreadCount = await RongIMLib.getTotalUnreadCountByLevels(conversationTypes, levels);
    console.info('获取会话指定免打扰级别的未读数结果:', totalUnreadCount);

    Parameters

    • conversationTypes: ConversationType[]

      会话类型列表,

    • levels: NotificationLevel[]

      需要获取的会话的免打扰级别,传空数组则统计全部支持会话未读数的会话类型的免打扰级别的未读数

    Returns Promise<IAsyncRes<number>>

    返回一个 IAsyncRes 类型 Promise,data 中返回会话未读数

getTotalUnreadMentionedCountByLevels

  • 获取会话指定免打扰级别未读 @ 消息数

    description

    查找免打扰配置符合传入的免打扰级别的会话,返回所有会话中所有未读 @ 消息的总数

    since

    5.5.1 暂不支持 Electron 平台

    example

    获取会话指定免打扰级别未读 @ 消息数示例:

    const conversationTypes = [RongIMLib.ConversationType.PRIVATE];
    const levels = [RongIMLib.NotificationLevel.ALL_MESSAGE];
    const totalUnreadCount = await RongIMLib.getTotalUnreadMentionedCountByLevels(conversationTypes, levels);
    console.info('获取会话指定免打扰级别未读 @ 消息数结果:', totalUnreadCount);

    Parameters

    Returns Promise<IAsyncRes<number>>

    返回一个 IAsyncRes 类型 Promise,data 中返回会话未读数

getUnreadCount

  • 获取指定会话的未读数

    description

    获取指定会话的未读数,Web 端会话未读数保存在 localstorage 中,如清除浏览器缓存会导致会话未读数不准确

    example

    获取指定会话的未读数示例:

    const options = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    }
    const unreadCount = await RongIMLib.getUnreadCount(options);
    console.info('获取指定会话的未读数结果:', unreadCount);

    Parameters

    Returns Promise<IAsyncRes<number>>

clearMessagesUnreadStatus

  • 清除指定会话未读数

    description

    清除指定会话的未读数(不含聊天室会话类型)

    • 注意
    1. Web 端会话未读数保存在 localstorage 中,如清除浏览器缓存会导致会话未读数不准确
    2. 聊天室会话类型不存储未读数,故不支持清除聊天室会话的未读数
    3. 未读数为本地为本地存储,清除后不可恢复,如用户多端未读数不会主动做多端同步,如需要多端同步需要通过 sendSyncReadStatusMessage 接口进行同步
    example

    清除指定会话未读数示例:

    const options = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    }
    const clearRes = await RongIMLib.clearMessagesUnreadStatus(options);
    console.info('清除指定会话未读数结果:', clearRes);

    Parameters

    Returns Promise<IAsyncRes<void>>

clearAllMessagesUnreadStatus

  • 清理全部未读数

    since

    5.0.2

    example

    清理全部未读数示例:

    const clearRes = await RongIMLib.clearAllMessagesUnreadStatus();
    console.info('清除指定会话未读数结果:', clearRes);

    Returns Promise<IAsyncRes<ErrorCode>>

getUnreadMentionedCount

  • 获取单个群会话 @ 消息未读数

    description

    获取当前用户在指定超级群会话指定频道的未读 @ 消息数。 注意,获取指定频道的未读 @ 消息数要求必须传入超级群频道 ID(channelId)

    example

    获取单个群会话 @ 消息未读数示例:

    const options = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    }
    const count = await RongIMLib.getUnreadMentionedCount(options);
    console.info('获取单个群会话 @ 消息未读数结果:', count);

    Parameters

    Returns Promise<IAsyncRes<number>>

    返回一个 IAsyncRes 类型 Promise,data 返回单个群会话 @ 消息未读数

getAllUnreadMentionedCount

  • getAllUnreadMentionedCount(): Promise<IAsyncRes<number>>
  • 获取所有群会话 @ 消息未读数

    description

    仅支持普通群会话,暂不支持超级群

    since

    5.9.0

    example

    获取所有群会话 @ 消息未读数示例:

    const count = await RongIMLib.getAllUnreadMentionedCount();
    console.info('获取所有群会话 @ 消息未读数结果:', count);

    Returns Promise<IAsyncRes<number>>

    返回一个 IAsyncRes 类型 Promise,data 返回所有群会话 @ 消息未读总数

标签

addTag

  • 创建标签

    description

    创建标签系统,用于对会话进行管理。SDK 创建的标签会被同步到服务端 SDK 支持使用一个或多个标签标记会话,可用于会话的分组显示、获取会话列表等操作,并提供了多个接口用于移除会话上的标签

    • 注意:每个用户最多可以创建 20 个标签
    example

    创建标签示例:

    const tag = {
    tagId: 'tagId',
    tagName: 'tagName',
    };
    const res = await RongIMLib.addTag(tag);
    console.log('创建标签结果:', res);

    Parameters

    Returns Promise<IAsyncRes<void>>

    创建成功返回 code 为 0,失败返回错误码

removeTag

  • removeTag(tagId: string): Promise<IAsyncRes<void>>
  • 删除标签

    example

    删除标签示例:

    const tagId = 'tagId';
    const res = await RongIMLib.removeTag(tagId);
    console.log('删除标签结果:', res);

    Parameters

    • tagId: string

      标签 ID

    Returns Promise<IAsyncRes<void>>

    删除成功返回 code 为 0,失败返回错误码

updateTag

  • 编辑标签

    description

    编辑标签名称,标签名称最大长度为 15 个字符, 标签 ID,长度不能超过 10 个字符

    example

    编辑标签示例:

    const tag = {
    tagId: 'tagId',
    tagName: 'tagName',
    };
    const res = await RongIMLib.updateTag(tag);
    console.log('编辑标签结果:', res);

    Parameters

    Returns Promise<IAsyncRes<void>>

    编辑成功返回 code 为 0,失败返回错误码

getTags

  • 获取标签列表

    description

    获取当前用户的标签列表

    example

    获取标签列表示例:

    const res = await RongIMLib.getTags();
    console.log('获取标签列表结果:', res);

    Returns Promise<IAsyncRes<ITagInfo[] | undefined>>

    返回一个 IAsyncRes 类型 Promise,data 为标签列表,类型为 ITagInfo 数组或者 undefined

getTagsFromConversation

  • 获取会话下的标签

    description

    更具会话信息获取具体某个会话下的标签列表

    example

    获取会话下的标签示例:

    const conversation = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    };
    const res = await RongIMLib.getTagsFromConversation(conversation);
    console.log('获取会话下的标签结果:', res);

    Parameters

    Returns Promise<IAsyncRes<IConversationTag[] | undefined>>

    返回一个 IAsyncRes 类型 Promise,data 为标签列表,类型为 IConversationTag 数组或者 undefined

addConversationsToTag

  • 添加会话到指定标签

    description

    添加会话到指定标签,一个会话可以添加到多个标签

    • 注意
    1. 每个标签下最多可以添加 1000 个会话
    2. 如果标签下已添加 1000 个会话,继续在该标签下添加会话仍会成功,但会导致最早添加标签的会话被移除标签
    3. 同一个会话可以设置多个不同的标签
    example

    添加会话到指定标签示例:

    const tagId = 'tagId';
    const conversations = [{
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    }];
    const res = await RongIMLib.addConversationsToTag(tagId, conversations);
    console.log('添加会话到指定标签结果:', res);

    Parameters

    Returns Promise<IAsyncRes<void>>

removeConversationsFromTag

  • 从指定标签中删除多个会话

    description

    从指定标签中删除多个会话,此操作仅解除会话与标签的关系,并不会删除会话数据

    example

    从指定标签中删除多个会话示例:

    const tagId = 'tagId';
    const conversations = [{
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    }];
    const res = await RongIMLib.removeConversationsFromTag(tagId, conversations);
    console.log('从指定标签中删除多个会话果:', res);

    Parameters

    Returns Promise<IAsyncRes<void>>

removeTagsFromConversation

  • 从指定会话中删除多个标签

    description

    从指定会话中删除多个标签,此操作仅解除会话与标签的关系,并不会删除会话数据

    example

    从指定会话中删除多个标签示例:

    const conversation = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    };
    const tagIds = ['tagId1', 'tagId2'];
    const res = await RongIMLib.removeTagsFromConversation(conversation, tagIds);
    console.log('从指定会话中删除多个标签结果:', res);

    Parameters

    Returns Promise<IAsyncRes<void>>

removeTagFromConversations

  • 从多个会话中删除指定的标签

    description

    从多个会话中删除指定的标签,此操作仅解除会话与标签的关系,并不会删除会话数据

    example

    从多个会话中删除指定的标签示例:

    const tagId = 'tagId';
    const conversations = [{
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    }];
    const res = await RongIMLib.removeTagFromConversations(tagId, conversations);
    console.log('从多个会话中删除指定的标签:', res);

    Parameters

    Returns Promise<IAsyncRes<void>>

getConversationsFromTagByPage

  • 分页获取标签下会话列表

    example

    分页获取标签下会话列表示例:

    const tagId = 'tagId';
    const count = 10;
    const timestamp = 0;
    const res = await RongIMLib.getConversationsFromTagByPage(tagId, count, timestamp);
    console.log('分页获取标签下会话列表结果:', res);

    Parameters

    • tagId: string

      标签id

    • count: number

      获取数量

    • startTime: number

    Returns Promise<IAsyncRes<IAReceivedConversationByTag[] | undefined>>

    返回一个 IAsyncRes 类型 Promise,data 为会话列表,类型为 IAReceivedConversationByTag 数组或者 undefined 从 SDK 版本 @since 5.7.0 开始该接口的返回数据类型由 IReceivedConversationByTag 变更为 IAReceivedConversationByTag

getUnreadCountByTag

  • getUnreadCountByTag(tagId: string, containMuted: boolean): Promise<IAsyncRes<number | undefined>>
  • 根据标签获取未读消息数

    example

    根据标签获取未读消息数示例:

    const tagId = 'tagId';
    const containMuted = false;
    const res = await RongIMLib.getUnreadCountByTag(tagId, containMuted);
    console.log('根据标签获取未读消息数结果:', res);

    Parameters

    • tagId: string

      标签id

    • containMuted: boolean

      是否包含免打扰

    Returns Promise<IAsyncRes<number | undefined>>

setConversationToTopInTag

  • 设置标签中会话置顶

    description

    设置在指定标签下置顶的会话。如果根据标签获取会话,可在获取的会话中可以看到该属性。请注意与会话列表中的会话置顶相区分

    example

    设置标签中会话置顶示例:

    const tagId = 'tagId';
    const conversation = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    };
    const isTop = true;
    const res = await RongIMLib.setConversationToTopInTag(tagId, conversation, isTop);
    console.log('设置标签中会话置顶结果:', res);

    Parameters

    Returns Promise<IAsyncRes<void>>

草稿

getTextMessageDraft

  • 获取会话文本草稿

    description

    Web 端草稿为内存态保存,如刷新浏览器会导致已经设置的草稿丢失

    example

    获取会话文本草稿示例:

    const options = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    }
    const conversation = await RongIMLib.getTextMessageDraft(options);
    console.info('获取会话文本草稿结果:', conversation);

    Parameters

    Returns Promise<IAsyncRes<string>>

saveTextMessageDraft

  • 设置会话文本草稿

    description

    Web 端草稿为内存态保存,如刷新浏览器会导致已经设置的草稿丢失

    example

    设置会话文本草稿示例:

    const options = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    }
    const draft = '这是草稿信息';
    const conversation = await RongIMLib.saveTextMessageDraft(options, draft);
    console.info('设置会话文本草稿结果:', conversation);

    Parameters

    Returns Promise<IAsyncRes<void>>

clearTextMessageDraft

  • 删除会话文本草稿

    example

    删除会话文本草稿示例:

    const options = {
    conversationType: RongIMLib.ConversationType.PRIVATE,
    targetId: 'targetId',
    }
    const conversation = await RongIMLib.clearTextMessageDraft(options);
    console.info('删除会话文本草稿结果:', conversation);

    Parameters

    Returns Promise<IAsyncRes<void>>

黑名单

addToBlacklist

  • addToBlacklist(userId: string): Promise<IAsyncRes<void>>
  • 加入黑名单

    description

    本功能暂仅限于在 Electron 解决方案中使用,将用户加入黑名单之后,将不再收到对方发来的任何单聊消息

    • 注意
    1. 加入黑名单为单向操作,例如:用户 A 拉黑用户 B,代表 B 无法给 A 发消息(错误码 405)。但 A 向 B 发消息,B 仍然能正常接收
    2. 单个用户的黑名单总人数存在上限,具体与计费套餐有关。IM 旗舰版与 IM 尊享版上限为 3000 人,其他套餐详见功能对照表中的服务限制
    3. 调用服务端 API 发送单聊消息默认不受黑名单限制。如需启用限制,请在调用 API 时设置 verifyBlacklist 为 1
    since

    5.4.0

    example

    加入黑名单示例:

    const userId = 'userId';
    const res = await RongIMLib.addToBlacklist(userId);
    console.log('加入黑名单结果:', res);

    Parameters

    • userId: string

      用户 ID

    Returns Promise<IAsyncRes<void>>

removeFromBlacklist

  • removeFromBlacklist(userId: string): Promise<IAsyncRes<void>>
  • 移出黑名单

    description

    本功能暂仅限于在 Electron 解决方案中使用, 将用户移出黑名单之后,将恢复接收对方发来的任何单聊消息

    since

    5.4.0

    example

    移出黑名单示例:

    const userId = 'userId';
    const res = await RongIMLib.removeFromBlacklist(userId);
    console.log('移出黑名单结果:', res);

    Parameters

    • userId: string

      用户 ID

    Returns Promise<IAsyncRes<void>>

getBlacklist

  • 获取黑名单列表

    description

    本功能暂仅限于在 Electron 解决方案中使用,用来获取黑名单列表

    since

    5.4.0

    example

    获取黑名单列表示例:

    const res = await RongIMLib.getBlacklist();
    console.log('获取黑名单列表结果:', res);

    Returns Promise<IAsyncRes<string[]>>

getBlacklistStatus

  • getBlacklistStatus(userId: string): Promise<IAsyncRes<boolean>>
  • 查询用户是否在黑名单中

    description

    本功能暂仅限于在 Electron 解决方案中使用,用来查询用户是否在黑名单中

    since

    5.4.0

    example

    获取黑名单列表示例:

    const userId = 'userId';
    const res = await RongIMLib.getBlacklistStatus(userId);
    console.log('获取黑名单列表结果:', res);

    Parameters

    • userId: string

      用户 ID

    Returns Promise<IAsyncRes<boolean>>

订阅用户状态

subscribeUserStatus

  • subscribeUserStatus(userIds: string[], subscribeType: SubscribeType, expiry: number): Promise<IAsyncRes<string[]>>
  • 订阅用户状态

    description

    此方法用于订阅一组用户的状态。当这些用户的状态发生变化时,将通过回调接口通知调用者 注意

    1. 一次订阅用户的上限为 200 个, 订阅的用户数最多为 1000 个,一个用户最多可以被 5000 个用户订阅
    2. 订阅用户在线状态能力需要开通服务,开通路径: IM 服务 > IM 服务管理 > 客户端用户在线状态订阅
    since

    5.9.8

    example

    订阅用户状态示例:

    const userIds = ['user1', 'user2'];
    const subscribeType = RongIMLib.SubscribeType.ONLINE_STATUS;
    // 设置订阅时间,取值范围为[60,2592000](单位:秒)。
    const expiry = 60;
    const res = await RongIMLib.subscribeUserStatus(userIds, subscribeType, expiry);
    console.log('订阅用户状态结果:', res);

    Parameters

    • userIds: string[]

      被订阅用户 ID 列表,一次最多订阅 200 个用户

    • subscribeType: SubscribeType

      订阅类型

    • expiry: number

      订阅有效期,取值范围为[60,2592000](单位:秒)

    Returns Promise<IAsyncRes<string[]>>

    返回一个 IAsyncRes 类型 Promise,订阅错误为 26021 时返回被订阅达上限(用户最多可以被 5000 个用户订阅)的用户 ID 列表

unSubscribeUserStatus

  • 取消订阅用户状态

    description

    此方法用于取消已经订阅的用户状态事件

    since

    5.9.8

    example

    取消订阅用户状态示例:

    const userIds = ['user1', 'user2'];
    const subscribeType = RongIMLib.SubscribeType.ONLINE_STATUS;
    const res = await RongIMLib.unSubscribeUserStatus(userIds, subscribeType);
    console.log('取消订阅用户状态结果:', res);

    Parameters

    • userIds: string[]

      被订阅用户 ID 列表,一次最多传递 200 个用户

    • subscribeType: SubscribeType

      订阅类型, 可在 SubscribeType 中获取

    Returns Promise<IAsyncRes<void>>

getSubscribeUserList

  • 分页查询已订阅用户的状态信息

    description

    此方法用于获取当前所有订阅的事件的状态信息(仅支持在线状态类型)

    since

    5.9.8

    example

    分页查询已订阅用户的状态信息示例:

    const pageSize = 10;
    const offset = 0;
    const subscribeType = RongIMLib.SubscribeType.ONLINE_STATUS;
    const res = await RongIMLib.getSubscribeUserList(subscribeType, pageSize, offset);
    console.log('分页查询已订阅用户的状态信息结果:', res);

    Parameters

    • subscribeType: SubscribeType
    • pageSize: number

      数量

    • offset: number

      分页偏移量

    Returns Promise<IAsyncRes<ISubscribeUserStatusInfo[]>>

    返回一个 IAsyncRes 类型 Promise,其中 data 为 ISubscribeUserStatusInfo 类型数组

getSubscribeUserStatus

  • 查询订阅状态信息

    description

    查询指定用户和订阅类型的状态信息。 一次最多查询 200 个用户的状态信息

    since

    5.9.8

    example

    查询订阅状态信息示例:

    const userIds = ['user1', 'user2'];
    const subscribeType = RongIMLib.SubscribeType.ONLINE_STATUS;
    const res = await RongIMLib.getSubscribeUserStatus(subscribeType, userIds);
    console.log('查询订阅状态信息结果:', res);

    Parameters

    • subscribeType: SubscribeType
    • userIds: string[]

      被订阅用户 ID 列表, 列表不可为空,且一次最多查询 200 个用户的状态信息

    Returns Promise<IAsyncRes<ISubscribeUserStatusInfo[]>>

    返回一个 IAsyncRes 类型 Promise,其中 data 为 ISubscribeUserStatusInfo 类型数组

用户资料

updateMyUserProfile

  • 更新用户资料

    description

    此方法用于更新当前用户的资料信息

    since

    5.10.1

    example

    更新用户资料示例:

    const profile = {
    name: 'name',
    portraitUri: 'portraitUri',
    email: 'email',
    birthday: 'birthday',
    gender: 1,
    location: 'location',
    role: 1,
    level: 1,
    extraProfile: {
    key1: 'value1',
    key2: 'value2',
    },
    }
    const res = await RongIMLib.updateMyUserProfile(profile);
    console.log('更新用户资料结果:', res);

    Parameters

    Returns Promise<IAsyncRes<{ errorKey: string }>>

    返回一个 IAsyncRes 类型 Promise,其中 data 为 { errorKey: string } 类型

getUserProfiles

  • 批量获取用户资料

    description

    此方法用于批量获取用户的资料信息

    since

    5.10.1

    example

    批量获取用户资料示例:

    const userIds = ['user1', 'user2'];
    const res = await RongIMLib.getUserProfiles(userIds);
    console.log('批量获取用户资料结果:', res);

    Parameters

    • userIds: string[]

      用户ID 列表,一次最多获取 100 个

    Returns Promise<IAsyncRes<IUserProfileInfo[]>>

    返回一个 IAsyncRes 类型 Promise,其中 data 为 IUserProfileInfo 类型数组

getMyUserProfile

  • 获取当前用户资料

    description

    此方法用于获取当前用户的资料信息

    since

    5.10.1

    example

    获取当前用户资料示例:

    const res = await RongIMLib.getMyUserProfile();
    console.log('获取当前用户资料结果:', res);

    Returns Promise<IAsyncRes<IUserProfileInfo>>

    返回一个 IAsyncRes 类型 Promise,其中 data 为 IUserProfileInfo 类型

updateMyUserProfileVisibility

  • 用户权限设置

    description

    此方法用于设置用户信息权限

    since

    5.10.1

    example

    用户权限设置示例:

    const visibility = RongIMLib.UserProfileVisibility.EVERYONE;
    const res = await RongIMLib.updateMyUserProfileVisibility(visibility);
    console.log('用户权限设置结果:', res);

    Parameters

    Returns Promise<IAsyncRes<void>>

    返回一个 IAsyncRes 类型 Promise,其中 data 为 void 类型

getMyUserProfileVisibility

  • 用户权限获取

    description

    此方法用于获取用户信息权限

    since

    5.10.1

    example

    用户权限获取示例:

    const res = await RongIMLib.getMyUserProfileVisibility();
    console.log('用户权限获取结果:', res);

    Returns Promise<IAsyncRes<UserProfileVisibility>>

    返回一个 IAsyncRes 类型 Promise,其中 data 为 UserProfileVisibility 类型

searchUserProfileByUniqueId

  • 按用户应用号精确搜索用户信息

    description

    此方法用于按用户应用号精确搜索用户信息

    since

    5.10.1

    example

    按用户应用号精确搜索用户信息示例:

    const uniqueId = 'uniqueId';
    const res = await RongIMLib.searchUserProfileByUniqueId(uniqueId);
    console.log('按用户应用号精确搜索用户信息结果:', res);

    Parameters

    • uniqueId: string

      用户应用号

    Returns Promise<IAsyncRes<IUserProfileInfo>>

    返回一个 IAsyncRes 类型 Promise,其中 data 为 IUserProfileInfo 类型

Type

IChatroomRejoinedInfo

聊天室重新加入信息

IPromiseResult

IPromiseResult<T>: Promise<IAsyncRes<T>>

异步任务结果定义

description

通过 Promise.resolve 来处理预期内的异常,进而通过 Uncatch Promise Error 暴露预期外的异常

Type parameters

  • T = void

IRemoveChatRoomEntries

IRemoveChatRoomEntries: IRemoveChatroomEntries

定义已废弃,请使用 IRemoveChatroomEntries 替换

deprecated

IChatRoomEntry

IChatRoomEntry: IChatroomEntry

定义已废弃,请使用 IChatroomEntry 替换

deprecated

IChatRoomEntries

IChatRoomEntries: IChatroomEntries

定义已废弃,请使用 IChatroomEntries 替换

deprecated

IRemoveChatRoomEntry

IRemoveChatRoomEntry: IRemoveChatroomEntry

定义已废弃,请使用 IRemoveChatroomEntry 替换

deprecated

EnableLogL

EnableLogL: DEBUG | INFO | WARN | ERROR

有效的日志等级声明

IEventListener

IEventListener: (...args: any[]) => void

Type declaration

    • (...args: any[]): void
    • 事件监听器

      Parameters

      • Rest ...args: any[]

      Returns void

ISendBody

ISendBody: IUserInfo & IExtraData & { file: File } & IMentionedInfo & IAuditInfo

发送消息基础类型

ISendFileMessageOptions

ISendFileMessageOptions: ISendBody

发送文件消息配置项

ISendImageMessageOptions

ISendImageMessageOptions: ISendBody

发送图片消息配置项

ISendSightMessageOptions

ISendSightMessageOptions: { duration: number; thumbnail: string; name?: string } & ISendBody

发送小视频消息配置项

MessageConstructor

MessageConstructor<T>: new (content: T) => BaseMessage<T>

Type parameters

  • T

Type declaration

MentionedInfo

MentionedInfo: { type?: 1 | 2; userIdList?: string[] }

@ 类型

Type declaration

  • Optional type?: 1 | 2

    @ 类型,其中 1 为 @ 所有人,2 为 @ 部分人

  • Optional userIdList?: string[]

    被 @ 的用户 Id 列表,仅在 type2 时有效

IInitOption

IInitOption: { appkey: string; logLevel?: LogLevel; logOutputLevel?: EnableLogL; logStdout?: any; navigators?: string[]; connectType?: "websocket" | "comet"; customCMP?: string[]; indexDBSwitch?: boolean; checkCA?: boolean; uploadDomain?: string; httpInMainProcess?: boolean; logExpireTime?: number; areaCode?: AreaCode; logServerUrl?: string; environment?: string }

初始化配置项

Type declaration

  • appkey: string

    应用 appkey 标识

  • Optional logLevel?: LogLevel

    该配置已废弃,请使用 logOutputLevel 替代。

    deprecated

    修改 SDK 内部日志打印等级,默认为 LogLevel.WARN

  • Optional logOutputLevel?: EnableLogL

    修改内部日志打印等级,默认输出 LogL.WARN 及以上级别

  • logStdout?:function
    • logStdout(logLevel: LogLevel, content: string): void
    • deprecated
      • 配置已废弃

      Parameters

      Returns void

  • Optional navigators?: string[]

    自定义导航地址,公有云用户不推荐修改

  • Optional connectType?: "websocket" | "comet"

    连接方式,默认使用 'websocket'

    deprecated

    自 5.6.0 版本开始,不再支持 Comet 连接,该配置项失效。

  • Optional customCMP?: string[]

    小程序平台专属配置

  • Optional indexDBSwitch?: boolean
    deprecated

    是否打开 IndexDB 存储, 默认为 true

  • Optional checkCA?: boolean
    deprecated

    已废弃,默认不再在 Electron 平台下校验导航服务的 CA 问题

  • Optional uploadDomain?: string

    七牛上传文件地址域名(仅私有云 RCX 服务支持)

  • Optional httpInMainProcess?: boolean

    开启后,SDK 内的 HTTP 请求将由 Electron 主进程内发送。

    since

    5.6.0

    description

    仅在 Electron 环境中搭配 @rongcloud/electron-renderer@rongcloud/electron 包时有效。

    • 当值为 true 时,HTTP 请求由 Electron 主进程内发送,不受浏览器安全沙箱策略限制。
    • 当值为 false 时,保持使用 Chromium 的 XMLHttpRequest 发送 HTTP 协议请求, 请求由渲染进程内发出,受浏览器安全沙箱策略限制。
    defautl

    false

  • Optional logExpireTime?: number

    IndexDB 数据库内的日志有效期,单位为小时,有效值为 24 - 168,默认 IndexDB 内日志数据有效期 168 小时

  • Optional areaCode?: AreaCode

    区域码

    since

    5.7.9

  • Optional logServerUrl?: string

    日志上报服务地址

    since

    5.7.7

  • Optional environment?: string

    私有云环境配置

GetHistoryMessageOption

GetHistoryMessageOption: { timestamp?: number; count?: number; order?: 0 | 1 }

获取历史消息配置项

Type declaration

  • Optional timestamp?: number

    获取此时间之前的消息,0 为从当前时间拉取

  • Optional count?: number

    获取消息的数量,范围: 1-100 如果 SDK < 5.7.4,范围为 [1-20];如果 SDK ≧ 5.7.4,范围为 [1-100]。默认值 20

  • Optional order?: 0 | 1

    获取消息的排列顺序

    • 0: 升序
    • 1: 降序

GetHistoryMessageResult

GetHistoryMessageResult: { list: IAReceivedMessage[]; hasMore: boolean }

获取历史消息返回结构

Type declaration

EventListeners

EventListeners: { CONNECTING: any; CONNECTED: any; DISCONNECT: any; SUSPEND: any; MESSAGES: any; READ_RECEIPT_RECEIVED: any; MESSAGE_RECEIPT_REQUEST: any; MESSAGE_RECEIPT_RESPONSE: any; CONVERSATION: any; CHATROOM: any; EXPANSION: any; PULL_OFFLINE_MESSAGE_FINISHED: any; TAG: any; CONVERSATION_TAG: any; TYPING_STATUS: any; MESSAGE_BLOCKED: any; ULTRA_GROUP_ENABLE: any; OPERATE_STATUS: any; ULTRA_GROUP_MESSAGE_EXPANSION_UPDATED: any; ULTRA_GROUP_MESSAGE_MODIFIED: any; ULTRA_GROUP_MESSAGE_RECALLED: any; ULTRA_GROUP_CHANNEL_TYPE_CHANGE: any; ULTRA_GROUP_CHANNEL_DELETE: any; ULTRA_GROUP_CHANNEL_USER_KICKED: any; USER_GROUP_STATUS: any; MESSAGE_READ_RECEIPT_V4: any; SUBSCRIBED_USER_STATUS_CHANGE: any; SUBSCRIBED_RELATION_CHANGE: any; SYNC_SUBSCRIBED_USER_STATUS_FINISHED: any; OWN_USER_PROFILE_CHANGED: any; DATABASE_UPGRADE_WILL_START: any; DATABASE_UPGRADING: any; DATABASE_UPGRADE_DID_COMPLETE: any }

事件监听器

Type declaration

  • CONNECTING:function
    • CONNECTING(): void
    • Returns void

  • CONNECTED:function
    • CONNECTED(): void
    • Returns void

  • DISCONNECT:function
    • Parameters

      Returns void

  • SUSPEND:function
    • Parameters

      Returns void

  • MESSAGES:function
    • Parameters

      Returns void

  • READ_RECEIPT_RECEIVED:function
  • MESSAGE_RECEIPT_REQUEST:function
  • MESSAGE_RECEIPT_RESPONSE:function
  • CONVERSATION:function
    • Parameters

      Returns void

  • CHATROOM:function
  • EXPANSION:function
  • PULL_OFFLINE_MESSAGE_FINISHED:function
    • PULL_OFFLINE_MESSAGE_FINISHED(): void
    • Returns void

  • TAG:function
    • TAG(): void
    • Returns void

  • CONVERSATION_TAG:function
    • CONVERSATION_TAG(): void
    • Returns void

  • TYPING_STATUS:function
    • Parameters

      Returns void

  • MESSAGE_BLOCKED:function
  • ULTRA_GROUP_ENABLE:function
  • OPERATE_STATUS:function
  • ULTRA_GROUP_MESSAGE_EXPANSION_UPDATED:function
    • Parameters

      Returns void

  • ULTRA_GROUP_MESSAGE_MODIFIED:function
    • Parameters

      Returns void

  • ULTRA_GROUP_MESSAGE_RECALLED:function
    • Parameters

      Returns void

  • ULTRA_GROUP_CHANNEL_TYPE_CHANGE:function
  • ULTRA_GROUP_CHANNEL_DELETE:function
  • ULTRA_GROUP_CHANNEL_USER_KICKED:function
  • USER_GROUP_STATUS:function
  • MESSAGE_READ_RECEIPT_V4:function
    • MESSAGE_READ_RECEIPT_V4(data: IReadReceiptData): void
    • Parameters

      • data: IReadReceiptData

      Returns void

  • SUBSCRIBED_USER_STATUS_CHANGE:function
  • SUBSCRIBED_RELATION_CHANGE:function
  • SYNC_SUBSCRIBED_USER_STATUS_FINISHED:function
    • Parameters

      Returns void

  • OWN_USER_PROFILE_CHANGED:function
    • Parameters

      Returns void

  • DATABASE_UPGRADE_WILL_START:function
    • DATABASE_UPGRADE_WILL_START(): void
    • Returns void

  • DATABASE_UPGRADING:function
    • DATABASE_UPGRADING(progress: number): void
    • Parameters

      • progress: number

      Returns void

  • DATABASE_UPGRADE_DID_COMPLETE:function
    • DATABASE_UPGRADE_DID_COMPLETE(code: ErrorCode): void
    • Parameters

      Returns void

其他

CombineMessage

CombineV2Message

CombineV2Message: MessageConstructor<CombineV2MessageContent>

CommandMessage

FileMessage

GIFMessage

GroupNotificationMessage

HQVoiceMessage

ImageMessage

InformationNotificationMessage

LocationMessage

ReferenceMessage

RichContentMessage

SightMessage

TextMessage

VoiceMessage