createChatThread method

Future<EMChatThread> createChatThread({
  1. required String name,
  2. required String messageId,
  3. required String parentId,
})

~english Create Chat Thread.

Group members have permission. After chat thread is created, the following notices will appear:

  1. Members of the organization (group) to which chat thread belongs will receive the created notification event, and can listen to related events by setting EMChatThreadEventHandler. The event callback function is EMChatThreadEventHandler.onChatThreadCreate.
  2. Multiple devices will receive the notification event and you can set EMMultiDeviceEventHandler to listen on the event. The event callback function is EMMultiDeviceEventHandler.onChatThreadEvent, where the first parameter is the event, for example, EMMultiDevicesEvent.CHAT_THREAD_CREATE for the chat thread creation event.

Param name Chat Thread name. No more than 64 characters in length.

Param messageId Parent message ID, generally refers to group message ID.

Param parentId Parent ID, generally refers to group ID.

Return EMChatThread object

Throws A description of the exception. See EMError. ~end

~chinese 创建子区。

@note 所有群成员都可以调用。 子区创建成功后,会出现如下情况:

Param name 要创建的子区的名称。长度不超过 64 个字符。

Param messageId 父消息 ID。

Param parentId 群组 ID。

Return 调用成功时,返回创建的子区对象;失败则抛出异常。

Throws 如果有异常会在此抛出,包括错误码和错误信息,详见 EMError。 ~end

Implementation

Future<EMChatThread> createChatThread({
  required String name,
  required String messageId,
  required String parentId,
}) async {
  Map req = {
    "name": name,
    "messageId": messageId,
    "parentId": parentId,
  };
  Map result = await _channel.invokeMethod(
    ChatMethodKeys.createChatThread,
    req,
  );
  try {
    EMError.hasErrorFromResult(result);
    return EMChatThread.fromJson(result[ChatMethodKeys.createChatThread]);
  } on EMError catch (e) {
    throw e;
  }
}