From bfaaf4d3c2becabea8965f13c54716b3359f7f7b Mon Sep 17 00:00:00 2001 From: dujiepeng <347302029@qq.com> Date: Tue, 29 Nov 2022 11:04:33 +0800 Subject: [PATCH 1/3] fix bugs. --- .../easemob/im_flutter_sdk/EMChatManagerWrapper.java | 7 +++---- .../com/easemob/im_flutter_sdk/EMClientWrapper.java | 5 +++-- ios/Classes/EMChatManagerWrapper.m | 4 ++-- ios/Classes/EMClientWrapper.m | 11 +++++++++-- ios/Classes/EMConversationWrapper.m | 4 ++-- ios/Classes/EMOptions+Helper.m | 1 + lib/src/em_chat_manager.dart | 6 +++--- 7 files changed, 23 insertions(+), 15 deletions(-) diff --git a/android/src/main/java/com/easemob/im_flutter_sdk/EMChatManagerWrapper.java b/android/src/main/java/com/easemob/im_flutter_sdk/EMChatManagerWrapper.java index 32f24582..477ce82c 100644 --- a/android/src/main/java/com/easemob/im_flutter_sdk/EMChatManagerWrapper.java +++ b/android/src/main/java/com/easemob/im_flutter_sdk/EMChatManagerWrapper.java @@ -46,8 +46,6 @@ public class EMChatManagerWrapper extends EMWrapper implements MethodCallHandler } - - @Override public void onMethodCall(MethodCall call, Result result) { JSONObject param = (JSONObject) call.arguments; @@ -239,6 +237,7 @@ private void ackGroupMessageRead(JSONObject param, String channelName, Result re asyncRunnable(()->{ try { EMClient.getInstance().chatManager().ackGroupMessageRead(to, msgId, finalContent); + onSuccess(result, channelName, true); } catch (HyphenateException e) { onError(result, e); } @@ -536,12 +535,12 @@ private void fetchHistoryMessages(JSONObject param, String channelName, Result r private void searchChatMsgFromDB(JSONObject param, String channelName, Result result) throws JSONException { String keywords = param.getString("keywords"); - long timeStamp = param.getLong("timeStamp"); + long timestamp = param.getLong("timestamp"); int count = param.getInt("maxCount"); String from = param.getString("from"); EMSearchDirection direction = searchDirectionFromString(param.getString("direction")); asyncRunnable(() -> { - List msgList = EMClient.getInstance().chatManager().searchMsgFromDB(keywords, timeStamp, count, + List msgList = EMClient.getInstance().chatManager().searchMsgFromDB(keywords, timestamp, count, from, direction); List messages = new ArrayList<>(); for (EMMessage msg : msgList) { diff --git a/android/src/main/java/com/easemob/im_flutter_sdk/EMClientWrapper.java b/android/src/main/java/com/easemob/im_flutter_sdk/EMClientWrapper.java index ad53dca8..2ea04afe 100644 --- a/android/src/main/java/com/easemob/im_flutter_sdk/EMClientWrapper.java +++ b/android/src/main/java/com/easemob/im_flutter_sdk/EMClientWrapper.java @@ -129,7 +129,7 @@ else if (EMSDKMethod.isConnected.equals(call.method)) { else if (EMSDKMethod.renewToken.equals(call.method)){ renewToken(param, call.method, result); } else if (EMSDKMethod.startCallback.equals(call.method)) { - startCallback(); + startCallback(param, call.method, result); } else { super.onMethodCall(call, result); @@ -311,8 +311,9 @@ private void getLoggedInDevicesFromServer(JSONObject param, String channelName, }); } - private void startCallback() { + private void startCallback(JSONObject param, String channelName, Result result) { EMListenerHandle.getInstance().startCallback(); + onSuccess(result, channelName, null); } private void bindingManagers() { diff --git a/ios/Classes/EMChatManagerWrapper.m b/ios/Classes/EMChatManagerWrapper.m index 823a70aa..74435d4e 100644 --- a/ios/Classes/EMChatManagerWrapper.m +++ b/ios/Classes/EMChatManagerWrapper.m @@ -648,12 +648,12 @@ - (void)searchChatMsgFromDB:(NSDictionary *)param result:(FlutterResult)result { __weak typeof(self) weakSelf = self; NSString *keywords = param[@"keywords"]; - long long timeStamp = [param[@"timeStamp"] longLongValue]; + long long timestamp = [param[@"timestamp"] longLongValue]; int maxCount = [param[@"maxCount"] intValue]; NSString *from = param[@"from"]; EMMessageSearchDirection direction = [self searchDirectionFromString:param[@"direction"]]; [EMClient.sharedClient.chatManager loadMessagesWithKeyword:keywords - timestamp:timeStamp + timestamp:timestamp count:maxCount fromUser:from searchDirection:direction diff --git a/ios/Classes/EMClientWrapper.m b/ios/Classes/EMClientWrapper.m index 391f33c2..02d5136d 100644 --- a/ios/Classes/EMClientWrapper.m +++ b/ios/Classes/EMClientWrapper.m @@ -170,7 +170,9 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { channelName:call.method result:result]; }else if ([ChatStartCallback isEqualToString:call.method]){ - [self startCallBack]; + [self startCallBack:call.arguments + channelName:call.method + result:result]; } else { [super handleMethodCall:call result:result]; @@ -439,8 +441,13 @@ - (void)getLoggedInDevicesFromServer:(NSDictionary *)param channelName:(NSString }]; } -- (void)startCallBack { +- (void)startCallBack:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result{ + __weak typeof(self)weakSelf = self; [EMListenerHandle.sharedInstance startCallback]; + [weakSelf wrapperCallBack:result + channelName:aChannelName + error:nil + object:nil]; } #pragma - mark EMClientDelegate diff --git a/ios/Classes/EMConversationWrapper.m b/ios/Classes/EMConversationWrapper.m index f7b22032..895bfacb 100644 --- a/ios/Classes/EMConversationWrapper.m +++ b/ios/Classes/EMConversationWrapper.m @@ -345,7 +345,7 @@ - (void)loadMsgWithMsgType:(NSDictionary *)param channelName:(NSString *)aChanne __weak typeof(self) weakSelf = self; EMMessageBodyType type = [EMMessageBody typeFromString:param[@"msgType"]]; - long long timeStamp = [param[@"timeStamp"] longLongValue]; + long long timestamp = [param[@"timestamp"] longLongValue]; int count = [param[@"count"] intValue]; NSString *sender = param[@"sender"]; EMMessageSearchDirection direction = [self searchDirectionFromString:param[@"direction"]]; @@ -355,7 +355,7 @@ - (void)loadMsgWithMsgType:(NSDictionary *)param channelName:(NSString *)aChanne { [conversation loadMessagesWithType:type - timestamp:timeStamp + timestamp:timestamp count:count fromUser:sender searchDirection:direction diff --git a/ios/Classes/EMOptions+Helper.m b/ios/Classes/EMOptions+Helper.m index 8cd09b9d..e736acda 100644 --- a/ios/Classes/EMOptions+Helper.m +++ b/ios/Classes/EMOptions+Helper.m @@ -57,6 +57,7 @@ + (EMOptions *)fromJson:(NSDictionary *)aJson { options.restServer = aJson[@"restServer"]; options.dnsURL = aJson[@"dnsURL"]; options.area = [aJson[@"areaCode"] intValue]; + return options; } @end diff --git a/lib/src/em_chat_manager.dart b/lib/src/em_chat_manager.dart index 59a29a46..1444a6c2 100644 --- a/lib/src/em_chat_manager.dart +++ b/lib/src/em_chat_manager.dart @@ -585,7 +585,7 @@ class EMChatManager { /// /// Param [keywords] The keywords in message. /// - /// Param [timeStamp] The Unix timestamp for search, in milliseconds. + /// Param [timestamp] The Unix timestamp for search, in milliseconds. /// /// Param [maxCount] The maximum number of messages to retrieve each time. /// @@ -597,14 +597,14 @@ class EMChatManager { /// Future> searchMsgFromDB( String keywords, { - int timeStamp = -1, + int timestamp = -1, int maxCount = 20, String from = '', EMSearchDirection direction = EMSearchDirection.Up, }) async { Map req = Map(); req['keywords'] = keywords; - req['timeStamp'] = timeStamp; + req['timestamp'] = timestamp; req['maxCount'] = maxCount; req['from'] = from; req['direction'] = direction == EMSearchDirection.Up ? "up" : "down"; From 4d1aee385760a615ad9abbcfe67e391f884503e8 Mon Sep 17 00:00:00 2001 From: dujiepeng <347302029@qq.com> Date: Tue, 29 Nov 2022 11:52:51 +0800 Subject: [PATCH 2/3] update android load conversations api. --- .../java/com/easemob/im_flutter_sdk/EMChatManagerWrapper.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/android/src/main/java/com/easemob/im_flutter_sdk/EMChatManagerWrapper.java b/android/src/main/java/com/easemob/im_flutter_sdk/EMChatManagerWrapper.java index 477ce82c..542ecd15 100644 --- a/android/src/main/java/com/easemob/im_flutter_sdk/EMChatManagerWrapper.java +++ b/android/src/main/java/com/easemob/im_flutter_sdk/EMChatManagerWrapper.java @@ -435,6 +435,10 @@ public void onError(int code, String desc) { } private void loadAllConversations(JSONObject param, String channelName, Result result) throws JSONException { + if (EMClient.getInstance().getCurrentUser() == null || EMClient.getInstance().getCurrentUser().length() == 0) { + onSuccess(result, channelName, new ArrayList<>()); + return; + } List list = new ArrayList<>(EMClient.getInstance().chatManager().getAllConversations().values()); asyncRunnable(() -> { boolean retry = false; From dc5213cfac08049a1091fed9ca364489792244e6 Mon Sep 17 00:00:00 2001 From: dujiepeng <347302029@qq.com> Date: Tue, 29 Nov 2022 11:56:05 +0800 Subject: [PATCH 3/3] update version to 3972 --- CHANGELOG.md | 6 ++++++ pubspec.yaml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23b20c86..8f471350 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ ## NEXT +## 3.9.7+2 + +修复: +1. 修复 StartCallback() 不会回调的问题; +2. 修复 iOS 根据时间获取消息失败的问题; + ## 3.9.7+1 修复: diff --git a/pubspec.yaml b/pubspec.yaml index 1d4b54f3..4fa5fcc7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: im_flutter_sdk description: Integrate the Chat SDK to enjoy the global IM services with high reliability, ultra-low latency, and high concurrency. -version: 3.9.7+1 +version: 3.9.7+2 homepage: https://www.easemob.com/product/im environment: