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 ChatError. ~end

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

Return 会话的消息未读数量。

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

Implementation

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