Skip to content

Commit a8a50b2

Browse files
authored
Merge pull request #537 from easemob/dev_3.9.9+1
Dev 3.9.9+1
2 parents 03bfafb + 2b8b773 commit a8a50b2

File tree

13 files changed

+143
-25
lines changed

13 files changed

+143
-25
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
## NEXT
22

3+
4+
# 3.9.9+1
5+
修复:
6+
1. 修复ios群已读回执不执行;
7+
8+
新增:
9+
1. 增加会话根据时间删除服务器漫游消息api `EMConversation#removeServerMessageBeforeTimeStamp(timestamp)`
10+
311
# 3.9.9
412
修复:
5-
修复极端情况下 SDK 崩溃的问题。
13+
1.修复极端情况下 SDK 崩溃的问题。
614

715
## 3.9.7+4
816
修复:

android/src/main/java/com/easemob/im_flutter_sdk/EMConversationWrapper.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.hyphenate.chat.EMMessage;
1313
import com.hyphenate.chat.EMMessageBody;
1414

15+
import org.json.JSONArray;
1516
import org.json.JSONException;
1617
import org.json.JSONObject;
1718

@@ -84,6 +85,12 @@ else if (EMSDKMethod.loadMsgWithTime.equals(call.method)) {
8485
else if(EMSDKMethod.messageCount.equals(call.method)) {
8586
messageCount(param, call.method, result);
8687
}
88+
else if (EMSDKMethod.removeMsgFromServerWithMsgList.equals(call.method)) {
89+
removeMsgFromServerWithMsgList(param, call.method, result);
90+
}
91+
else if (EMSDKMethod.removeMsgFromServerWithTimeStamp.equals(call.method)) {
92+
removeMsgFromServerWithTimeStamp(param, call.method, result);
93+
}
8794
else
8895
{
8996
super.onMethodCall(call, result);
@@ -311,6 +318,22 @@ private void messageCount(JSONObject params, String channelName, Result result)
311318
});
312319
}
313320

321+
private void removeMsgFromServerWithMsgList(JSONObject params, String channelName, Result result) throws JSONException {
322+
JSONArray jsonAry = params.getJSONArray("msgIds");
323+
List<String> msgIds = new ArrayList<>();
324+
for (int i = 0; i < jsonAry.length(); i++) {
325+
msgIds.add((String) jsonAry.get(i));
326+
}
327+
EMConversation conversation = conversationWithParam(params);
328+
conversation.removeMessagesFromServer(msgIds, new EMWrapperCallBack(result, channelName, null));
329+
}
330+
331+
private void removeMsgFromServerWithTimeStamp(JSONObject params, String channelName, Result result) throws JSONException {
332+
long timestamp = params.getLong("timestamp");
333+
EMConversation conversation = conversationWithParam(params);
334+
conversation.removeMessagesFromServer(timestamp, new EMWrapperCallBack(result, channelName, null));
335+
}
336+
314337
private EMConversation conversationWithParam(JSONObject params ) throws JSONException {
315338
String con_id = params.getString("con_id");
316339
EMConversation.EMConversationType type = EMConversationHelper.typeFromInt(params.getInt("type"));

android/src/main/java/com/easemob/im_flutter_sdk/EMSDKMethod.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ public class EMSDKMethod {
127127
static final String loadMsgWithMsgType = "loadMsgWithMsgType";
128128
static final String loadMsgWithTime = "loadMsgWithTime";
129129
static final String messageCount = "messageCount";
130+
static final String removeMsgFromServerWithMsgList = "removeMsgFromServerWithMsgList";
131+
static final String removeMsgFromServerWithTimeStamp = "removeMsgFromServerWithTimeStamp";
130132

131133
// EMMessage method
132134
static final String getReactionList = "getReactionList";

example/ios/Flutter/AppFrameworkInfo.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
<key>CFBundleVersion</key>
2222
<string>1.0</string>
2323
<key>MinimumOSVersion</key>
24-
<string>9.0</string>
24+
<string>11.0</string>
2525
</dict>
2626
</plist>

example/ios/Runner/Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,7 @@
4343
</array>
4444
<key>UIViewControllerBasedStatusBarAppearance</key>
4545
<false/>
46+
<key>CADisableMinimumFrameDurationOnPhone</key>
47+
<true/>
4648
</dict>
4749
</plist>

ios/Classes/EMChatroomManagerWrapper.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ - (void)chatRoomMuteMembers:(NSDictionary *)param channelName:(NSString *)aChann
539539
__weak typeof(self) weakSelf = self;
540540

541541
NSArray *muteMembers = param[@"muteMembers"];
542-
NSInteger muteMilliseconds = [param[@"duration"] integerValue];
542+
long muteMilliseconds = [param[@"duration"] longValue];
543543
NSString *chatroomId = param[@"roomId"];
544544
[EMClient.sharedClient.roomManager muteMembers:muteMembers
545545
muteMilliseconds:muteMilliseconds

ios/Classes/EMConversationWrapper.m

Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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]];

ios/Classes/EMSDKMethod.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ static NSString *const ChatLoadMsgWithKeywords = @"loadMsgWithKeywords";
139139
static NSString *const ChatLoadMsgWithMsgType = @"loadMsgWithMsgType";
140140
static NSString *const ChatLoadMsgWithTime = @"loadMsgWithTime";
141141
static NSString *const ChatConversationMessageCount = @"messageCount";
142+
static NSString *const ChatRemoveMsgFromServerWithMsgList = @"removeMsgFromServerWithMsgList";
143+
static NSString *const ChatRemoveMsgFromServerWithTimeStamp = @"removeMsgFromServerWithTimeStamp";
142144

143145
#pragma mark - EMChatMessageWrapper
144146
static NSString *const ChatGetReactionList = @"getReactionList";

lib/src/em_chat_manager.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ class EMChatManager {
188188
///
189189
/// **Throws** A description of the exception. See [EMError].
190190
///
191-
Future<bool> sendGroupMessageReadAck(
191+
Future<void> sendGroupMessageReadAck(
192192
String msgId,
193193
String groupId, {
194194
String? content,
@@ -203,7 +203,6 @@ class EMChatManager {
203203
await ChatChannel.invokeMethod(ChatMethodKeys.ackGroupMessageRead, req);
204204
try {
205205
EMError.hasErrorFromResult(result);
206-
return result.boolValue(ChatMethodKeys.ackMessageRead);
207206
} on EMError catch (e) {
208207
throw e;
209208
}

lib/src/internal/chat_method_keys.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ class ChatMethodKeys {
137137
static const String loadMsgWithMsgType = "loadMsgWithMsgType";
138138
static const String loadMsgWithTime = "loadMsgWithTime";
139139
static const String messageCount = "messageCount";
140+
static const String removeMsgFromServerWithMsgList = "removeMsgFromServerWithMsgList";
141+
static const String removeMsgFromServerWithTimeStamp = "removeMsgFromServerWithTimeStamp";
140142

141143
/// EMMessage method
142144
static const String getReactionList = "getReactionList";

0 commit comments

Comments
 (0)