Skip to content

Commit

Permalink
Merge pull request #551 from easemob/dev_4.1.3
Browse files Browse the repository at this point in the history
Dev 4.1.3
  • Loading branch information
dujiepeng authored Oct 27, 2023
2 parents 909a18e + 64235ef commit 0d5be61
Show file tree
Hide file tree
Showing 25 changed files with 127 additions and 89 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## 4.1.3

#### 新增

- 支持 安卓 14;
- 新增 开启 荣耀推送开关 `EMOptions#enableHonorPush` 方法;

#### 修复

- 修复调用 `EMChatManager#getThreadConversation` 报错;
- 修复 `EMMessage#chatThread` 方法报错;
- 修复 `EMChatRoomEventHandler#onSpecificationChanged` 回调不执行。
- 修复 `EMChatThreadManager#fetchChatThreadMembers` 崩溃。
- 修复特殊场景下,安卓平台退出后再登录会丢失聊天室监听事件问题。
- 修复修改消息后,离线用户上线后拉取历史消息,消息体中缺乏 from 属性的问题。

## 4.1.0

#### 新增:
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ tasks.withType(JavaCompile){

dependencies {
api 'androidx.appcompat:appcompat:1.1.0'
implementation 'io.hyphenate:hyphenate-chat:4.1.1'
implementation 'io.hyphenate:hyphenate-chat:4.1.3'
}
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ public void onSpecificationChanged(EMChatRoom room) {
()-> {
Map<String, Object> data = new HashMap<>();
data.put("room", EMChatRoomHelper.toJson(room));
data.put("type", "onSpecificationChanged");
data.put("type", "onRoomSpecificationChanged");
post(() -> channel.invokeMethod(EMSDKMethod.chatRoomChange, data));
}
);
Expand Down
44 changes: 26 additions & 18 deletions android/src/main/java/com/easemob/im_flutter_sdk/EMHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ static EMOptions fromJson(JSONObject json, Context context) throws JSONException
if (pushConfig.getBoolean("enableVivoPush")) {
builder.enableVivoPush();
}
if(pushConfig.getBoolean("enableHonorPush")) {
builder.enableHonorPush();
}
options.setPushConfig(builder.build());
}
return options;
Expand Down Expand Up @@ -456,7 +459,7 @@ static EMMessage fromJson(JSONObject json) throws JSONException {
if (statusFromInt(json.getInt("status")) == EMMessage.Status.SUCCESS) {
message.setUnread(!json.getBoolean("hasRead"));
}
message.setDeliverAcked(json.getBoolean("hasDeliverAck"));
// message.setDeliverAcked(json.getBoolean("hasDeliverAck"));
message.setIsNeedGroupAck(json.getBoolean("needGroupAck"));
if (json.has("groupAckCount")) {
message.setGroupAckCount(json.getInt("groupAckCount"));
Expand Down Expand Up @@ -916,7 +919,7 @@ static EMVideoMessageBody videoBodyFromJson(JSONObject json) throws JSONExceptio
static Map<String, Object> videoBodyToJson(EMVideoMessageBody body) {
Map<String, Object> data = getParentMap(body);
data.put("localPath", body.getLocalUrl());
data.put("thumbnailLocalPath", body.getLocalThumbUri());
data.put("thumbnailLocalPath", body.getLocalThumb());
data.put("duration", body.getDuration());
data.put("thumbnailRemotePath", body.getThumbnailUrl());
data.put("thumbnailSecret", body.getThumbnailSecret());
Expand Down Expand Up @@ -1405,23 +1408,28 @@ static Map<String, Object> toJson(EMChatThread thread) {
class EMChatThreadEventHelper {
static Map<String, Object> toJson(EMChatThreadEvent event) {
Map<String, Object> data = new HashMap<>();
switch (event.getType()) {
case UNKNOWN:
data.put("type", 0);
break;
case CREATE:
data.put("type", 1);
break;
case UPDATE:
data.put("type", 2);
break;
case DELETE:
data.put("type", 3);
break;
case UPDATE_MSG:
data.put("type", 4);
break;
if(event.getType() != null) {
switch (event.getType()) {
case UNKNOWN:
data.put("type", 0);
break;
case CREATE:
data.put("type", 1);
break;
case UPDATE:
data.put("type", 2);
break;
case DELETE:
data.put("type", 3);
break;
case UPDATE_MSG:
data.put("type", 4);
break;
}
}else {
data.put("type", 0);
}

data.put("from", event.getFrom());
if (event.getChatThread() != null) {
data.put("thread", EMChatThreadHelper.toJson(event.getChatThread()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ private void getChatThread(JSONObject params, String channelName, MethodChannel.
String msgId = params.getString("msgId");
EMMessage msg = getMessageWithId(msgId);
asyncRunnable(()->{
if (msg == null) {
if (msg != null) {
onSuccess(result, channelName, msg.getChatThread() != null ? EMChatThreadHelper.toJson(msg.getChatThread()) : null);
}else {
onSuccess(result, channelName, null);
}
onSuccess(result, channelName, null);
});
}

Expand Down
8 changes: 4 additions & 4 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
PODS:
- Flutter (1.0.0)
- HyphenateChat (4.0.3)
- HyphenateChat (4.1.1)
- im_flutter_sdk (0.0.1):
- Flutter
- HyphenateChat (= 4.0.3)
- HyphenateChat (= 4.1.1)

DEPENDENCIES:
- Flutter (from `Flutter`)
Expand All @@ -21,8 +21,8 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
HyphenateChat: 35826ebaa42ebac897b39e29a06f2215a060011a
im_flutter_sdk: bbcfbe596ef4682c9518604e1cb319e967f6b163
HyphenateChat: 95aa4abbad0e763f513acbe21ff9543f50b886cd
im_flutter_sdk: 9242a0d080c2f4ade4a0247a21b034036320233e

PODFILE CHECKSUM: 7368163408c647b7eb699d0d788ba6718e18fb8d

Expand Down
5 changes: 3 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import 'package:flutter/material.dart';
import 'package:im_flutter_sdk/im_flutter_sdk.dart';

var appKey = "easemob-demo#flutter";
var appKey = "";

void main() async {
WidgetsFlutterBinding.ensureInitialized();
assert(appKey.isNotEmpty, "appKey is empty");
EMOptions options =
EMOptions(appKey: appKey, autoLogin: false, debugModel: true);
await EMClient.getInstance.init(options);
Expand Down Expand Up @@ -297,7 +298,7 @@ class _MyHomePageState extends State<MyHomePage> {
content: _messageContent,
);

EMClient.getInstance.chatManager.sendMessage(msg);
await EMClient.getInstance.chatManager.sendMessage(msg);
}

void _addLogToConsole(String log) {
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ packages:
path: ".."
relative: true
source: path
version: "4.0.3"
version: "4.1.3"
js:
dependency: transitive
description:
Expand Down
4 changes: 4 additions & 0 deletions ios/Classes/EMChatManagerWrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -1247,4 +1247,8 @@ - (void)onMessageContentChanged:(EMChatMessage *)message operatorId:(NSString *)
arguments:dict];
}

- (void)messageAttachmentStatusDidChange:(EMChatMessage *)aMessage error:(EMError *)aError {

}

@end
2 changes: 1 addition & 1 deletion ios/Classes/EMChatMessageWrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
} else if([ChatGroupAckCount isEqualToString:call.method]) {
[self getGroupAckCount:call.arguments channelName:call.method result:result];
} else if([ChatThread isEqualToString:call.method]) {

[self getChatThread:call.arguments channelName:call.method result:result];
}
else {
[super handleMethodCall:call result:result];
Expand Down
2 changes: 1 addition & 1 deletion ios/im_flutter_sdk.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ A new flutter plugin project.
s.public_header_files = 'Classes/**/*.h'

s.dependency 'Flutter'
s.dependency 'HyphenateChat','4.1.0'
s.dependency 'HyphenateChat','4.1.1'
s.ios.deployment_target = '11.0'

end
Expand Down
23 changes: 10 additions & 13 deletions lib/src/em_chat_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,7 @@ class EMChatManager {
///
/// **Throws** 如果有异常会在这里抛出,包含错误码和错误描述,详见 [EMError]
/// ~end
Future<EMMessage> sendMessage(
EMMessage message, {
void Function(
void Function(EMMessage)? onSuccess,
void Function(EMMessage)? onError,
void Function(int)? onProgress,
)? callback,
}) async {
Future<EMMessage> sendMessage(EMMessage message) async {
message.status = MessageStatus.PROGRESS;
Map result = await ChatChannel.invokeMethod(
ChatMethodKeys.sendMessage, message.toJson());
Expand Down Expand Up @@ -486,16 +479,20 @@ class EMChatManager {
///
/// **Throws** 如果有异常会在这里抛出,包含错误码和错误描述,详见 [EMError]
/// ~end
Future<EMConversation> getThreadConversation(String threadId) async {
Future<EMConversation?> getThreadConversation(String threadId) async {
Map result = await ChatChannel.invokeMethod(
ChatMethodKeys.getThreadConversation,
{"convId", threadId},
{"convId": threadId},
);

try {
EMConversation? ret;
EMError.hasErrorFromResult(result);
return EMConversation.fromJson(
result[ChatMethodKeys.getThreadConversation]);
if (result[ChatMethodKeys.getThreadConversation] != null) {
ret = EMConversation.fromJson(
result[ChatMethodKeys.getThreadConversation]);
}
return ret;
} on EMError catch (e) {
throw e;
}
Expand Down Expand Up @@ -1696,7 +1693,7 @@ class EMChatManager {
/// 只能调用该方法修改单聊和群聊中的文本消息,不能修改聊天室消息。
///
/// Param [messageId] 消息实例 ID。
///
///
/// Param [msgBody] 文本消息体实例 [EMTextMessageBody]
///
/// **Return** 修改后的消息实例。
Expand Down
4 changes: 2 additions & 2 deletions lib/src/em_chat_room_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ class EMChatRoomManager {
/// ~end
Future<void> blockChatRoomMembers(
String roomId,
List members,
List<String> members,
) async {
Map req = {"roomId": roomId, "members": members};
Map result =
Expand Down Expand Up @@ -947,7 +947,7 @@ class EMChatRoomManager {
/// ~end
Future<void> unBlockChatRoomMembers(
String roomId,
List members,
List<String> members,
) async {
Map req = {"roomId": roomId, "members": members};
Map result =
Expand Down
16 changes: 6 additions & 10 deletions lib/src/em_chat_thread_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,11 @@ class EMChatThreadManager {
///
/// Param [limit] 每页期望返回的成员数。取值范围为 [1,50]
///
/// **Return** 若调用成功,返回子区成员列表;失败则抛出异常。
/// **Return** 若调用成功,返回子区成员 [EMCursorResult];失败则抛出异常。
///
/// **Throws** 如果有异常会在此抛出,包括错误码和错误信息,详见 [EMError]
/// ~end
Future<List<String>> fetchChatThreadMembers({
Future<EMCursorResult<String>> fetchChatThreadMembers({
required String chatThreadId,
String? cursor,
int limit = 20,
Expand All @@ -329,13 +329,9 @@ class EMChatThreadManager {
);
try {
EMError.hasErrorFromResult(result);
List<String> list = [];
result[ChatMethodKeys.fetchChatThreadMember]?.forEach((element) {
if (element is String) {
list.add(element);
}
});
return list;
return EMCursorResult<String>.fromJson(
result[ChatMethodKeys.fetchChatThreadMember],
dataItemCallback: (obj) => obj);
} on EMError catch (e) {
throw e;
}
Expand Down Expand Up @@ -379,7 +375,7 @@ class EMChatThreadManager {
}

for (var key in map.keys) {
Map<String, Object> msgMap = map[key].cast<Map<String, Object>>();
Map<String, dynamic> msgMap = map[key];
ret[key] = EMMessage.fromJson(msgMap);
}
return ret;
Expand Down
6 changes: 3 additions & 3 deletions lib/src/em_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ class EMClient {
/// ~chinese
/// 获取指定账号下登录的在线设备列表。
///
/// Param [userId] 用户 ID。
/// Param [userId] 用户 ID。
///
/// Param [pwdOrToken] 密码或者 token。
///
Expand Down Expand Up @@ -906,8 +906,8 @@ class EMClient {

Future<void> _onMultiDeviceThreadEvent(Map map) async {
EMMultiDevicesEvent event = convertIntToEMMultiDevicesEvent(map['event'])!;
String target = map['target'];
List<String> users = map['users'];
String target = map['target'] ?? '';
List<String> users = map.getList("users") ?? [];

for (var handler in _multiDeviceEventHandler.values) {
handler.onChatThreadEvent?.call(event, target, users);
Expand Down
Loading

0 comments on commit 0d5be61

Please sign in to comment.