getThreadConversation method

Future<EMConversation?> getThreadConversation(
  1. String threadId
)

~english Gets the thread conversation by thread ID.

Param threadId The thread ID.

Return The conversation object.

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

~chinese 根据 thread ID 获取 thread 会话。

Param threadId Thread ID.

Return 会话对象.

Throws 如果有异常会在这里抛出,包含错误码和错误描述,详见 EMError。 ~end

Implementation

Future<EMConversation?> getThreadConversation(String threadId) async {
  try {
    Map req = {"convId": threadId};
    Map result = await Client.instance.chatManager
        .callNativeMethod(ChatMethodKeys.getThreadConversation, req);
    EMError.hasErrorFromResult(result);
    if (result.containsKey(ChatMethodKeys.getThreadConversation)) {
      return EMConversation.fromJson(
          result[ChatMethodKeys.getThreadConversation]);
    } else {
      return null;
    }
  } catch (e) {
    rethrow;
  }
}