sendMessage method

Future sendMessage ({@required JMNormalMessage message, JMMessageSendOptions sendOption })

message 可能是 JMTextMessage | JMVoiceMessage | JMImageMessage | JMFileMessage | JMCustomMessage; NOTE: 不要传接收到的消息进去,只能传通过 createMessage 创建的消息。

Implementation

Future<dynamic> sendMessage({
  @required JMNormalMessage message,
  JMMessageSendOptions sendOption
  }) async {
  Map param = message.target.targetType.toJson();

  Map optionMap = {};

  if (sendOption != null) {
      optionMap = {'messageSendingOptions': sendOption.toJson()..removeWhere((key,value) => value == null)};
  }

  param..addAll(optionMap)..addAll({'id': message.id});
  Map resMap = await _channel.invokeMethod('sendDraftMessage',
  param..removeWhere((key,value) => value == null));
  var res = JMNormalMessage.generateMessageFromJson(resMap);
  return res;
}