unreadCount method

Future<int> unreadCount()

~english Gets the unread message count of the conversation.

Return The unread message count of the conversation.

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

~chinese 获取会话的消息未读数。

Return 会话的消息未读数量。

Throws 如果有异常会在此抛出,包含错误码和原因,详见 EMError。 ~end

Implementation

Future<int> unreadCount() async {
  Map req = this._toJson();
  Map result = await _emConversationChannel.invokeMethod(
      ChatMethodKeys.getUnreadMsgCount, req);
  try {
    EMError.hasErrorFromResult(result);
    if (result.containsKey(ChatMethodKeys.getUnreadMsgCount)) {
      return result[ChatMethodKeys.getUnreadMsgCount];
    } else {
      return 0;
    }
  } on EMError catch (e) {
    throw e;
  }
}