@@ -97,6 +97,14 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
9797 [self messageCount: call.arguments
9898 channelName: call.method
9999 result: result];
100+ } else if ([ChatRemoveMsgFromServerWithMsgList isEqualToString: call.method]) {
101+ [self removeMsgFromServerWithMsgList: call.arguments
102+ channelName: call.method
103+ result: result];
104+ } else if ([ChatRemoveMsgFromServerWithTimeStamp isEqualToString: call.method]) {
105+ [self removeMsgFromServerWithTimeStamp: call.arguments
106+ channelName: call.method
107+ result: result];
100108 }
101109 else {
102110 [super handleMethodCall: call result: result];
@@ -140,7 +148,7 @@ - (void)getLatestMessage:(NSDictionary *)param
140148 __weak typeof (self) weakSelf = self;
141149 [self getConversationWithParam: param
142150 completion: ^(EMConversation *conversation)
143- {
151+ {
144152 EMChatMessage *msg = conversation.latestMessage ;
145153 [weakSelf wrapperCallBack: result
146154 channelName: aChannelName
@@ -156,7 +164,7 @@ - (void)getLatestMessageFromOthers:(NSDictionary *)param
156164 __weak typeof (self) weakSelf = self;
157165 [self getConversationWithParam: param
158166 completion: ^(EMConversation *conversation)
159- {
167+ {
160168 EMChatMessage *msg = conversation.lastReceivedMessage ;
161169 [weakSelf wrapperCallBack: result
162170 channelName: aChannelName
@@ -172,7 +180,7 @@ - (void)markMessageAsRead:(NSDictionary *)param
172180 __weak typeof (self) weakSelf = self;
173181 [self getConversationWithParam: param
174182 completion: ^(EMConversation *conversation)
175- {
183+ {
176184 NSString *msgId = param[@" msg_id" ];
177185 EMError *error = nil ;
178186 [conversation markMessageAsReadWithId: msgId error: &error];
@@ -191,7 +199,7 @@ - (void)syncConversationExt:(NSDictionary *)param
191199 __weak typeof (self) weakSelf = self;
192200 [self getConversationWithParam: param
193201 completion: ^(EMConversation *conversation)
194- {
202+ {
195203 NSDictionary *ext = param[@" ext" ];
196204 conversation.ext = ext;
197205 [weakSelf wrapperCallBack: result
@@ -224,7 +232,7 @@ - (void)insertMessage:(NSDictionary *)param
224232 __weak typeof (self) weakSelf = self;
225233 [self getConversationWithParam: param
226234 completion: ^(EMConversation *conversation)
227- {
235+ {
228236 NSDictionary *msgDict = param[@" msg" ];
229237 EMChatMessage *msg = [EMChatMessage fromJson: msgDict];
230238
@@ -244,7 +252,7 @@ - (void)appendMessage:(NSDictionary *)param
244252 __weak typeof (self) weakSelf = self;
245253 [self getConversationWithParam: param
246254 completion: ^(EMConversation *conversation)
247- {
255+ {
248256 NSDictionary *msgDict = param[@" msg" ];
249257 EMChatMessage *msg = [EMChatMessage fromJson: msgDict];
250258
@@ -264,7 +272,7 @@ - (void)updateConversationMessage:(NSDictionary *)param
264272 __weak typeof (self) weakSelf = self;
265273 [self getConversationWithParam: param
266274 completion: ^(EMConversation *conversation)
267- {
275+ {
268276 NSDictionary *msgDict = param[@" msg" ];
269277 EMChatMessage *msg = [EMChatMessage fromJson: msgDict];
270278
@@ -296,7 +304,7 @@ - (void)removeMessage:(NSDictionary *)param channelName:(NSString *)aChannelName
296304 __weak typeof (self) weakSelf = self;
297305 [self getConversationWithParam: param
298306 completion: ^(EMConversation *conversation)
299- {
307+ {
300308 NSString *msgId = param[@" msg_id" ];
301309 EMError *error = nil ;
302310 [conversation deleteMessageWithId: msgId error: &error];
@@ -322,6 +330,36 @@ - (void)clearAllMessages:(NSDictionary *)param channelName:(NSString *)aChannelN
322330 }];
323331}
324332
333+ - (void )removeMsgFromServerWithMsgList : (NSDictionary *)param channelName : (NSString *)aChannelName result : (FlutterResult)result
334+ {
335+ __weak typeof (self) weakSelf = self;
336+ [self getConversationWithParam: param
337+ completion: ^(EMConversation *conversation){
338+ NSArray *msgIds = param[@" msgIds" ];
339+ [conversation removeMessagesFromServerMessageIds: msgIds completion: ^(EMError * _Nullable aError) {
340+ [weakSelf wrapperCallBack: result
341+ channelName: aChannelName
342+ error: aError
343+ object: nil ];
344+ }];
345+ }];
346+ }
347+
348+ - (void )removeMsgFromServerWithTimeStamp : (NSDictionary *)param channelName : (NSString *)aChannelName result : (FlutterResult)result
349+ {
350+ __weak typeof (self) weakSelf = self;
351+ [self getConversationWithParam: param
352+ completion: ^(EMConversation *conversation){
353+ long timestamp = [param[@" timestamp" ] longValue ];
354+ [conversation removeMessagesFromServerWithTimeStamp: timestamp completion: ^(EMError * _Nullable aError) {
355+ [weakSelf wrapperCallBack: result
356+ channelName: aChannelName
357+ error: aError
358+ object: nil ];
359+ }];
360+ }];
361+ }
362+
325363#pragma mark - load messages
326364- (void )loadMsgWithId : (NSDictionary *)param channelName : (NSString *)aChannelName result : (FlutterResult)result
327365{
@@ -352,15 +390,15 @@ - (void)loadMsgWithMsgType:(NSDictionary *)param channelName:(NSString *)aChanne
352390
353391 [self getConversationWithParam: param
354392 completion: ^(EMConversation *conversation)
355- {
393+ {
356394
357395 [conversation loadMessagesWithType: type
358396 timestamp: timestamp
359397 count: count
360398 fromUser: sender
361399 searchDirection: direction
362400 completion: ^(NSArray *aMessages, EMError *aError)
363- {
401+ {
364402 NSMutableArray *msgJsonAry = [NSMutableArray array ];
365403 for (EMChatMessage *msg in aMessages) {
366404 [msgJsonAry addObject: [msg toJson ]];
@@ -381,12 +419,12 @@ - (void)loadMsgWithStartId:(NSDictionary *)param channelName:(NSString *)aChanne
381419 EMMessageSearchDirection direction = [self searchDirectionFromString: param[@" direction" ]];
382420
383421 [self getConversationWithParam: param
384- completion: ^(EMConversation *conversation) {
422+ completion: ^(EMConversation *conversation) {
385423 [conversation loadMessagesStartFromId: startId
386424 count: count
387425 searchDirection: direction
388426 completion: ^(NSArray *aMessages, EMError *aError)
389- {
427+ {
390428 NSMutableArray *jsonMsgs = [NSMutableArray array ];
391429 for (EMChatMessage *msg in aMessages) {
392430 [jsonMsgs addObject: [msg toJson ]];
@@ -410,15 +448,15 @@ - (void)loadMsgWithKeywords:(NSDictionary *)param channelName:(NSString *)aChann
410448 EMMessageSearchDirection direction = [self searchDirectionFromString: param[@" direction" ]];
411449 [self getConversationWithParam: param
412450 completion: ^(EMConversation *conversation)
413- {
451+ {
414452
415453 [conversation loadMessagesWithKeyword: keywords
416454 timestamp: timestamp
417455 count: count
418456 fromUser: sender
419457 searchDirection: direction
420458 completion: ^(NSArray *aMessages, EMError *aError)
421- {
459+ {
422460 NSMutableArray *msgJsonAry = [NSMutableArray array ];
423461 for (EMChatMessage *msg in aMessages) {
424462 [msgJsonAry addObject: [msg toJson ]];
@@ -438,13 +476,13 @@ - (void)loadMsgWithTime:(NSDictionary *)param channelName:(NSString *)aChannelNa
438476 int count = [param[@" count" ] intValue ];
439477 [self getConversationWithParam: param
440478 completion: ^(EMConversation *conversation)
441- {
479+ {
442480
443481 [conversation loadMessagesFrom: startTime
444482 to: entTime
445483 count: count
446484 completion: ^(NSArray *aMessages, EMError *aError)
447- {
485+ {
448486 NSMutableArray *msgJsonAry = [NSMutableArray array ];
449487 for (EMChatMessage *msg in aMessages) {
450488 [msgJsonAry addObject: [msg toJson ]];
0 commit comments