lastReceivedMessage method

Future<ChatMessage?> lastReceivedMessage()

~english Gets the latest message from the conversation.

Return The message instance. ~end

~chinese 获取最近收到的一条消息。

Return 消息体实例。 ~end

Implementation

Future<ChatMessage?> lastReceivedMessage() async {
  Map req = this._toJson();
  Map result = await _emConversationChannel.invokeMethod(
      ChatMethodKeys.getLatestMessageFromOthers, req);
  try {
    ChatError.hasErrorFromResult(result);
    if (result.containsKey(ChatMethodKeys.getLatestMessageFromOthers)) {
      return ChatMessage.fromJson(
          result[ChatMethodKeys.getLatestMessageFromOthers]);
    } else {
      return null;
    }
  } on ChatError catch (e) {
    throw e;
  }
}