insertIncomingMessage static method
插入一条收到的消息
conversationType
会话类型,参见枚举 RCConversationType
targetId
会话 id
senderUserId
发送者 id
receivedStatus
接收状态 参见枚举 RCReceivedStatus
content
消息内容,参见 MessageContent
sendTime
发送时间
finished
回调结果,会告知具体的消息和对应的错�����码
Implementation
static Future<void> insertIncomingMessage(int conversationType, String targetId, String senderUserId, int receivedStatus, MessageContent content, int sendTime, Function(Message? msg, int? code)? finished) async {
String? jsonStr = content.encode();
String? objName = content.getObjectName();
Map map = {"conversationType": conversationType, "targetId": targetId, "senderUserId": senderUserId, "rececivedStatus": receivedStatus, "objectName": objName, "content": jsonStr, "sendTime": sendTime};
Map msgMap = await _channel.invokeMethod(RCMethodKey.InsertIncomingMessage, map);
String? msgString = msgMap["message"];
int? code = msgMap["code"];
if (msgString == null) {
if (finished != null) {
finished(null, code);
}
return;
}
Message? message = MessageFactory.instance!.string2Message(msgString);
if (finished != null) {
finished(message, code);
}
}