insertMessage method

Future<void> insertMessage(
  1. ChatMessage message
)

Inserts a message to a conversation in the local database and the SDK will automatically update the last message.

Make sure you set the conversation ID as that of the conversation where you want to insert the message.

Param message The message instance.

Throws A description of the exception. See ChatError.

Implementation

Future<void> insertMessage(ChatMessage message) async {
  Map req = this._toJson();
  req['msg'] = message.toJson();
  Map result = await _emConversationChannel.invokeMethod(
      ChatMethodKeys.insertMessage, req);
  try {
    ChatError.hasErrorFromResult(result);
  } on ChatError catch (e) {
    throw e;
  }
}