From 3363953bafc4db235baca243039934cd0ec8f3f9 Mon Sep 17 00:00:00 2001 From: dujiepeng <347302029@qq.com> Date: Fri, 18 Mar 2022 15:17:51 +0800 Subject: [PATCH 1/5] update current user error. --- .../im_flutter_sdk/EMClientWrapper.java | 46 ++++---- .../easemob/im_flutter_sdk/EMSDKMethod.java | 6 +- example/lib/pages/chat/chat_page.dart | 4 +- example/lib/pages/index_page.dart | 14 +-- example/lib/pages/me/me_page.dart | 18 ++-- ios/Classes/EMClientWrapper.m | 25 +++-- ios/Classes/EMSDKMethod.h | 6 +- lib/src/chat_method_keys.dart | 6 +- lib/src/em_client.dart | 102 +++++++++--------- lib/src/em_userInfo_manager.dart | 8 +- lib/src/models/em_message.dart | 8 +- 11 files changed, 127 insertions(+), 116 deletions(-) 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 48aec65e..dfbd2bc1 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 @@ -107,6 +107,9 @@ else if (EMSDKMethod.getToken.equals(call.method)) { getToken(param, EMSDKMethod.getToken, result); } + else if (EMSDKMethod.isConnected.equals(call.method)) { + isConnected(param, call.method, result); + } else { super.onMethodCall(call, result); } @@ -116,10 +119,6 @@ else if (EMSDKMethod.getToken.equals(call.method)) } } - private void getToken(JSONObject param, String channelName, Result result) throws JSONException - { - onSuccess(result, channelName, EMClient.getInstance().getAccessToken()); - } private void createAccount(JSONObject param, String channelName, Result result) throws JSONException { String username = param.getString("username"); @@ -142,10 +141,7 @@ private void login(JSONObject param, String channelName, Result result) throws J @Override public void onSuccess() { post(() -> { - Map param = new HashMap<>(); - param.put("username", EMClient.getInstance().getCurrentUser()); - param.put("token", EMClient.getInstance().getAccessToken()); - object = param; + object = EMClient.getInstance().getCurrentUser(); super.onSuccess(); }); } @@ -186,6 +182,19 @@ private void getCurrentUser(JSONObject param, String channelName, Result result) onSuccess(result, channelName, EMClient.getInstance().getCurrentUser()); } + private void getToken(JSONObject param, String channelName, Result result) throws JSONException + { + onSuccess(result, channelName, EMClient.getInstance().getAccessToken()); + } + + private void isLoggedInBefore(JSONObject param, String channelName, Result result) throws JSONException { + onSuccess(result, channelName, EMClient.getInstance().isLoggedInBefore()); + } + + private void isConnected(JSONObject param, String channelName, Result result) throws JSONException{ + onSuccess(result, channelName, EMClient.getInstance().isConnected()); + } + private void updateCurrentUserNick(JSONObject param, String channelName, Result result) throws JSONException { String nickName = param.getString("nickname"); asyncRunnable(()->{ @@ -244,9 +253,6 @@ private void kickAllDevices(JSONObject param, String channelName, Result result) } - private void isLoggedInBefore(JSONObject param, String channelName, Result result) throws JSONException { - onSuccess(result, channelName, EMClient.getInstance().isLoggedInBefore()); - } private void onMultiDeviceEvent(JSONObject param, String channelName, Result result) throws JSONException { @@ -269,16 +275,6 @@ private void getLoggedInDevicesFromServer(JSONObject param, String channelName, }); } -// private void registerManagers() { -// new EMChatManagerWrapper(registrar, "em_chat_manager"); -// new EMContactManagerWrapper(registrar, "em_contact_manager"); -// new EMChatRoomManagerWrapper(registrar, "em_chat_room_manager"); -// new EMGroupManagerWrapper(registrar, "em_group_manager"); -// new EMConversationWrapper(registrar, "em_conversation"); -// new EMPushManagerWrapper(registrar, "em_push_manager"); -// new EMUserInfoManagerWrapper(registrar, "em_userInfo_manager"); -// } - private void bindingManagers() { new EMChatManagerWrapper(binging, "chat_manager"); new EMContactManagerWrapper(binging, "chat_contact_manager"); @@ -294,13 +290,7 @@ private void init(JSONObject param, String channelName, Result result) throws JS EMClient.getInstance().setDebugMode(param.getBoolean("debugModel")); bindingManagers(); addEMListener(); - - Map data = new HashMap<>(); - data.put("isLoginBefore", EMClient.getInstance().isLoggedInBefore()); - data.put("username", EMClient.getInstance().getCurrentUser()); - data.put("token", EMClient.getInstance().getAccessToken()); - data.put("currentUsername", EMClient.getInstance().getCurrentUser()); - onSuccess(result, channelName, data); + onSuccess(result, channelName, null); } private void addEMListener() { diff --git a/android/src/main/java/com/easemob/im_flutter_sdk/EMSDKMethod.java b/android/src/main/java/com/easemob/im_flutter_sdk/EMSDKMethod.java index 9d330c46..be776508 100644 --- a/android/src/main/java/com/easemob/im_flutter_sdk/EMSDKMethod.java +++ b/android/src/main/java/com/easemob/im_flutter_sdk/EMSDKMethod.java @@ -7,15 +7,17 @@ public class EMSDKMethod { static final String login = "login"; static final String logout = "logout"; static final String changeAppKey = "changeAppKey"; - static final String isLoggedInBefore = "isLoggedInBefore"; static final String updateCurrentUserNick = "updateCurrentUserNick"; static final String uploadLog = "uploadLog"; static final String compressLogs = "compressLogs"; static final String kickDevice = "kickDevice"; static final String kickAllDevices = "kickAllDevices"; static final String getLoggedInDevicesFromServer = "getLoggedInDevicesFromServer"; - static final String getCurrentUser = "getCurrentUser"; + static final String getToken = "getToken"; + static final String getCurrentUser = "getCurrentUser"; + static final String isLoggedInBefore = "isLoggedInBefore"; + static final String isConnected = "isConnected"; static final String onConnected = "onConnected"; static final String onDisconnected = "onDisconnected"; diff --git a/example/lib/pages/chat/chat_page.dart b/example/lib/pages/chat/chat_page.dart index 6dbd4125..6564d3bd 100644 --- a/example/lib/pages/chat/chat_page.dart +++ b/example/lib/pages/chat/chat_page.dart @@ -361,8 +361,8 @@ class _ChatPageState extends State _sendTextMessage(String txt) async { if (txt.length == 0) return; EMMessage msg = EMMessage.createTxtSendMessage( - widget.conversation.id, - txt, + username: widget.conversation.id, + content: txt, ); _sendMessage(msg); diff --git a/example/lib/pages/index_page.dart b/example/lib/pages/index_page.dart index e8691764..f4adfc51 100644 --- a/example/lib/pages/index_page.dart +++ b/example/lib/pages/index_page.dart @@ -35,12 +35,14 @@ class IndexPageState extends State { }); } - void toNextPage() { - if (EMClient.getInstance.isLoginBefore == true) { - Navigator.of(context).pushReplacementNamed('/home'); - } else { - Navigator.of(context).pushReplacementNamed('/login'); - } + void toNextPage() async { + await EMClient.getInstance.isLoginBefore().then((value) { + if (value == true) { + Navigator.of(context).pushReplacementNamed('/home'); + } else { + Navigator.of(context).pushReplacementNamed('/login'); + } + }); } @override diff --git a/example/lib/pages/me/me_page.dart b/example/lib/pages/me/me_page.dart index 3d59e8b3..5d1b387a 100644 --- a/example/lib/pages/me/me_page.dart +++ b/example/lib/pages/me/me_page.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:im_flutter_sdk/im_flutter_sdk.dart'; class MePage extends StatefulWidget { @@ -40,12 +41,6 @@ class MePageState extends State { ), textAlign: TextAlign.left, ), - Text( - EMClient.getInstance.flutterSDKVersion, - style: TextStyle( - fontSize: 14.0, - ), - ), ], ), ), @@ -58,7 +53,7 @@ class MePageState extends State { Colors.red, ), ), - onPressed: _loggout, + onPressed: _logout, child: Text( '退出[${EMClient.getInstance.currentUsername}]', style: TextStyle( @@ -75,13 +70,18 @@ class MePageState extends State { ); } - _loggout() async { + _logout() async { try { + SmartDialog.showLoading(msg: '退出中...'); await EMClient.getInstance.logout(true); Navigator.of(context).pushReplacementNamed( '/login', ); - } on EMError {} + } on EMError catch (e) { + SmartDialog.showToast('登录失败 $e'); + } finally { + SmartDialog.dismiss(); + } } goUserInfoPage() { diff --git a/ios/Classes/EMClientWrapper.m b/ios/Classes/EMClientWrapper.m index 7886f65c..4020b641 100644 --- a/ios/Classes/EMClientWrapper.m +++ b/ios/Classes/EMClientWrapper.m @@ -103,12 +103,18 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { { [self isLoggedInBefore:call.arguments result:result]; } - else if([EMMethodKeyCurrentUser isEqualToString:call.method]) + else if([EMMethodKeyGetCurrentUser isEqualToString:call.method]) { [self getCurrentUser:call.arguments result:result]; - }else if([EMMethodKeyGetToken isEqualToString:call.method]){ + } + else if([EMMethodKeyGetToken isEqualToString:call.method]) + { [self getToken:call.arguments result:result]; } + else if([EMMethodKeyIsConnected isEqualToString:call.method]) + { + [self isConnected:call.arguments result:result]; + } else { [super handleMethodCall:call result:result]; } @@ -121,6 +127,14 @@ - (void)getToken:(NSDictionary *)param result:(FlutterResult)result{ object:EMClient.sharedClient.accessUserToken]; } + +- (void)isConnected:(NSDictionary *)param result:(FlutterResult)result{ + [self wrapperCallBack:result + channelName:EMMethodKeyIsConnected + error:nil + object:@(EMClient.sharedClient.isConnected)]; +} + #pragma mark - Actions - (void)initSDKWithDict:(NSDictionary *)param result:(FlutterResult)result { @@ -189,10 +203,7 @@ - (void)login:(NSDictionary *)param result:(FlutterResult)result { [weakSelf wrapperCallBack:result channelName:EMMethodKeyLogin error:aError - object:@{ - @"username": aUsername, - @"token": EMClient.sharedClient.accessUserToken - }]; + object:EMClient.sharedClient.currentUsername]; }]; }else { [EMClient.sharedClient loginWithUsername:username @@ -236,7 +247,7 @@ - (void)getCurrentUser:(NSDictionary *)param result:(FlutterResult)result { __weak typeof(self) weakSelf = self; NSString* username = EMClient.sharedClient.currentUsername; [weakSelf wrapperCallBack:result - channelName:EMMethodKeyCurrentUser + channelName:EMMethodKeyGetCurrentUser error:nil object:username]; diff --git a/ios/Classes/EMSDKMethod.h b/ios/Classes/EMSDKMethod.h index 8d231a54..ed8e64e2 100644 --- a/ios/Classes/EMSDKMethod.h +++ b/ios/Classes/EMSDKMethod.h @@ -17,14 +17,16 @@ static NSString *const EMMethodKeyCreateAccount = @"createAccount"; static NSString *const EMMethodKeyLogin = @"login"; static NSString *const EMMethodKeyLogout = @"logout"; static NSString *const EMMethodKeyChangeAppKey = @"changeAppKey"; -static NSString *const EMMethodKeyIsLoggedInBefore = @"isLoggedInBefore"; static NSString *const EMMethodKeyUploadLog = @"uploadLog"; static NSString *const EMMethodKeyCompressLogs = @"compressLogs"; static NSString *const EMMethodKeyKickDevice = @"kickDevice"; static NSString *const EMMethodKeyKickAllDevices = @"kickAllDevices"; -static NSString *const EMMethodKeyCurrentUser = @"currentUser"; static NSString *const EMMethodKeyGetLoggedInDevicesFromServer = @"getLoggedInDevicesFromServer"; + static NSString *const EMMethodKeyGetToken = @"getToken"; +static NSString *const EMMethodKeyGetCurrentUser = @"getCurrentUser"; +static NSString *const EMMethodKeyIsLoggedInBefore = @"isLoggedInBefore"; +static NSString *const EMMethodKeyIsConnected = @"isConnected"; #pragma mark - EMClientDelegate static NSString *const EMMethodKeyOnConnected = @"onConnected"; diff --git a/lib/src/chat_method_keys.dart b/lib/src/chat_method_keys.dart index 197447ac..89d9668e 100644 --- a/lib/src/chat_method_keys.dart +++ b/lib/src/chat_method_keys.dart @@ -5,7 +5,7 @@ class ChatMethodKeys { static const String login = 'login'; static const String logout = 'logout'; static const String changeAppKey = 'changeAppKey'; - static const String isLoggedInBefore = 'isLoggedInBefore'; + static const String uploadLog = 'uploadLog'; static const String compressLogs = 'compressLogs'; static const String kickDevice = 'kickDevice'; @@ -13,7 +13,11 @@ class ChatMethodKeys { static const String currentUser = 'currentUser'; static const String getLoggedInDevicesFromServer = 'getLoggedInDevicesFromServer'; + static const String getToken = 'getToken'; + static const String getCurrentUser = 'getCurrentUser'; + static const String isLoggedInBefore = 'isLoggedInBefore'; + static const String isConnected = 'isConnected'; /// EMClient listener static const String onMultiDeviceEvent = 'onMultiDeviceEvent'; diff --git a/lib/src/em_client.dart b/lib/src/em_client.dart index 3c5793c1..a41563b6 100644 --- a/lib/src/em_client.dart +++ b/lib/src/em_client.dart @@ -1,5 +1,5 @@ import 'dart:async'; -import 'package:flutter/material.dart'; + import 'package:flutter/services.dart'; import 'em_chat_manager.dart'; import 'em_contact_manager.dart'; @@ -26,28 +26,16 @@ class EMClient { final List _multiDeviceListeners = []; final List _customListeners = []; - /// instance fields - bool _connected = false; EMOptions? _options; - String _sdkVersion = '1.0.0'; - - String? _currentUsername; - - bool _isLoginBefore = false; - /// 获取配置信息[EMOptions]. EMOptions? get options => _options; - /// 获取当前是否连接到服务器 - bool get connected => _connected; + String? _currentUsername; /// 获取当前登录的环信id String? get currentUsername => _currentUsername; - /// 获取是否登录 - bool get isLoginBefore => _isLoginBefore; - static EMClient get getInstance => _instance = _instance ?? EMClient._internal(); @@ -72,31 +60,59 @@ class EMClient { }); } + Future isConnected() async { + Map result = await _channel.invokeMethod(ChatMethodKeys.isConnected); + try { + EMError.hasErrorFromResult(result); + return result.boolValue(ChatMethodKeys.isConnected); + } on EMError catch (e) { + throw e; + } + } + + Future isLoginBefore() async { + Map result = await _channel.invokeMethod(ChatMethodKeys.isLoggedInBefore); + try { + EMError.hasErrorFromResult(result); + return result.boolValue(ChatMethodKeys.isLoggedInBefore); + } on EMError catch (e) { + throw e; + } + } + + Future getCurrentUsername() async { + Map result = await _channel.invokeMethod(ChatMethodKeys.getCurrentUser); + try { + EMError.hasErrorFromResult(result); + _currentUsername = result[ChatMethodKeys.getCurrentUser]; + if (_currentUsername != null) { + if (_currentUsername!.length == 0) { + _currentUsername = null; + } + } + return _currentUsername; + } on EMError catch (e) { + throw e; + } + } + /// 获取已登录账号的环信Token - Future getAccessToken() async { + Future getAccessToken() async { Map result = await _channel.invokeMethod(ChatMethodKeys.getToken); - EMError.hasErrorFromResult(result); - return result[ChatMethodKeys.getToken]; + try { + EMError.hasErrorFromResult(result); + return result[ChatMethodKeys.getToken]; + } on EMError catch (e) { + throw e; + } } /// 初始化SDK 指定[options]. Future init(EMOptions options) async { _options = options; EMLog.v('init: $options'); - // 直接返回当前登录账号和是否登陆过 - Map result = - await _channel.invokeMethod(ChatMethodKeys.init, options.toJson()); - Map map = result[ChatMethodKeys.init]; - _currentUsername = map['username']; - _isLoginBefore = () { - if (map.containsKey("isLoginBefore")) { - return map['isLoginBefore'] as bool; - } else { - return false; - } - }(); - - return null; + await _channel.invokeMethod(ChatMethodKeys.init, options.toJson()); + _currentUsername = await getCurrentUsername(); } /// 注册环信id,[username],[password], @@ -116,7 +132,7 @@ class EMClient { /// 使用用户名(环信id)和密码(或token)登录,[username], [pwdOrToken] /// 返回登录成功的id(环信id) - Future login(String username, String pwdOrToken, + Future login(String username, String pwdOrToken, [bool isPassword = true]) async { EMLog.v('login: $username : $pwdOrToken, isPassword: $isPassword'); Map req = { @@ -127,9 +143,7 @@ class EMClient { Map result = await _channel.invokeMethod(ChatMethodKeys.login, req); try { EMError.hasErrorFromResult(result); - _currentUsername = result[ChatMethodKeys.login]['username']; - _isLoginBefore = true; - return _currentUsername; + _currentUsername = result[ChatMethodKeys.login]; } on EMError catch (e) { throw e; } @@ -278,24 +292,19 @@ class EMClient { } } - /// @nodoc once connection changed, listeners to be informed. Future _onConnected() async { - _connected = true; for (var listener in _connectionListeners) { listener.onConnected(); } } - /// @nodoc Future _onDisconnected(Map? map) async { - _connected = false; for (var listener in _connectionListeners) { int? errorCode = map!['errorCode']; listener.onDisconnected(errorCode); } } - /// @nodoc on multi device event emitted, call listeners func. Future _onMultiDeviceEvent(Map map) async { var event = map['event']; for (var listener in _multiDeviceListeners) { @@ -310,33 +319,27 @@ class EMClient { } void _onReceiveCustomData(Map map) { - debugPrint("map ---- $map"); for (var listener in _customListeners) { listener.onDataReceived(map); } } - /// @nodoc chatManager - retrieve [EMChat Manager] handle. EMChatManager get chatManager { return _chatManager; } - /// @nodoc contactManager - retrieve [EMContactManager] handle. EMContactManager get contactManager { return _contactManager; } - /// @nodoc EMChatRoomManager get chatRoomManager { return _chatRoomManager; } - /// @nodoc groupManager - retrieve [EMGroupManager] handle. EMGroupManager get groupManager { return _groupManager; } - /// @nodoc pushManager - retrieve [EMPushManager] handle. EMPushManager get pushManager { return _pushManager; } @@ -345,7 +348,6 @@ class EMClient { return _userInfoManager; } - /// @nodoc EMContactGroupEvent? convertIntToEMContactGroupEvent(int? i) { switch (i) { case 2: @@ -403,12 +405,8 @@ class EMClient { } } - String get flutterSDKVersion => _sdkVersion; - void _clearAllInfo() { - _isLoginBefore = false; - _connected = false; - _currentUsername = ''; + _currentUsername = null; _userInfoManager.clearUserInfoCache(); } } diff --git a/lib/src/em_userInfo_manager.dart b/lib/src/em_userInfo_manager.dart index c6d6c66f..0cdc9922 100644 --- a/lib/src/em_userInfo_manager.dart +++ b/lib/src/em_userInfo_manager.dart @@ -55,11 +55,13 @@ class EMUserInfoManager { } Future fetchOwnInfo({int expireTime = 3600}) async { - if (EMClient.getInstance.currentUsername != null) { + String? currentUser = await EMClient.getInstance.getCurrentUsername(); + if (currentUser != null) { try { Map ret = await fetchUserInfoByIdWithExpireTime( - [EMClient.getInstance.currentUsername!], - expireTime: expireTime); + [currentUser], + expireTime: expireTime, + ); _ownUserInfo = ret.values.first; } on EMError catch (e) { throw e; diff --git a/lib/src/models/em_message.dart b/lib/src/models/em_message.dart index fd379787..a4f81588 100644 --- a/lib/src/models/em_message.dart +++ b/lib/src/models/em_message.dart @@ -199,10 +199,10 @@ class EMMessage { } /// 构造发送的文字消息 - EMMessage.createTxtSendMessage( - String username, - String content, - ) : this.createSendMessage( + EMMessage.createTxtSendMessage({ + required String username, + required String content, + }) : this.createSendMessage( to: username, body: EMTextMessageBody(content: content), ); From 714009fbf6b7f68593155618863cd3db48b32655 Mon Sep 17 00:00:00 2001 From: dujiepeng <347302029@qq.com> Date: Mon, 21 Mar 2022 18:14:42 +0800 Subject: [PATCH 2/5] change files. --- CHANGELOG.md | 6 + .../im_flutter_sdk/EMChatManagerWrapper.java | 40 +- .../EMChatRoomManagerWrapper.java | 122 +++--- .../im_flutter_sdk/EMClientWrapper.java | 28 +- .../EMContactManagerWrapper.java | 22 +- .../im_flutter_sdk/EMConversationWrapper.java | 34 +- .../im_flutter_sdk/EMGroupManagerWrapper.java | 94 ++--- .../com/easemob/im_flutter_sdk/EMHelper.java | 2 +- .../im_flutter_sdk/EMPushManagerWrapper.java | 20 +- .../EMUserInfoManagerWrapper.java | 8 +- example/lib/main.dart | 12 +- example/lib/pages/chat/chat_page.dart | 1 + .../conversations/conversation_item.dart | 2 +- .../conversations/conversations_page.dart | 2 +- ios/Classes/EMChatManagerWrapper.m | 42 +- ios/Classes/EMChatroomManagerWrapper.m | 226 ++++++---- ios/Classes/EMClientWrapper.m | 114 +++-- ios/Classes/EMContactManagerWrapper.m | 88 ++-- ios/Classes/EMConversationWrapper.m | 152 ++++--- ios/Classes/EMGroup+Flutter.m | 1 - ios/Classes/EMGroupManagerWrapper.m | 394 +++++++++++------- ios/Classes/EMPushManagerWrapper.m | 14 +- ios/Classes/EMUserInfoManagerWrapper.m | 28 +- lib/im_flutter_sdk.dart | 3 +- lib/src/em_group_manager.dart | 1 + lib/src/em_push_manager.dart | 10 +- lib/src/models/em_chat_room.dart | 48 +-- lib/src/models/em_conversation.dart | 8 +- lib/src/models/em_error.dart | 23 +- lib/src/models/em_group.dart | 98 ++--- lib/src/models/em_group_shared_file.dart | 36 ++ lib/src/models/em_options.dart | 240 ++++------- lib/src/models/em_push_config.dart | 150 +++---- lib/src/models/em_push_configs.dart | 109 +++++ lib/src/tools/em_extension.dart | 53 +++ pubspec.yaml | 2 +- 36 files changed, 1277 insertions(+), 956 deletions(-) create mode 100644 lib/src/models/em_group_shared_file.dart create mode 100644 lib/src/models/em_push_configs.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index b5d0dd45..8ae03271 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ ## NEXT +## 3.8.3+6 + +- 修改EMImPushConfig为EMPushConfigs; +- 删除EMOptions中的EMPushConfig.设置推送证书时直接调用EMOptions即可; +- EMGroup中移除ShareFiles,如果需要获取共享文件,请调用Api: + ```EMClient.getInstance.groupManager.getGroupFileListFromServer(groupId)``` ## 3.8.3+5 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 edfcef2c..7d90da54 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 @@ -48,45 +48,45 @@ public void onMethodCall(MethodCall call, Result result) { JSONObject param = (JSONObject) call.arguments; try { if (EMSDKMethod.sendMessage.equals(call.method)) { - sendMessage(param, EMSDKMethod.sendMessage, result); + sendMessage(param, call.method, result); } else if (EMSDKMethod.resendMessage.equals(call.method)) { - resendMessage(param, EMSDKMethod.resendMessage, result); + resendMessage(param, call.method, result); } else if (EMSDKMethod.ackMessageRead.equals(call.method)) { - ackMessageRead(param, EMSDKMethod.ackMessageRead, result); + ackMessageRead(param, call.method, result); } else if (EMSDKMethod.ackGroupMessageRead.equals(call.method)) { - ackGroupMessageRead(param, EMSDKMethod.ackGroupMessageRead, result); + ackGroupMessageRead(param, call.method, result); } else if (EMSDKMethod.ackConversationRead.equals(call.method)) { - ackConversationRead(param, EMSDKMethod.ackConversationRead, result); + ackConversationRead(param, call.method, result); } else if (EMSDKMethod.recallMessage.equals(call.method)) { - recallMessage(param, EMSDKMethod.recallMessage, result); + recallMessage(param, call.method, result); } else if (EMSDKMethod.getConversation.equals(call.method)) { - getConversation(param, EMSDKMethod.getConversation, result); + getConversation(param, call.method, result); } else if (EMSDKMethod.markAllChatMsgAsRead.equals(call.method)) { - markAllChatMsgAsRead(param, EMSDKMethod.markAllChatMsgAsRead, result); + markAllChatMsgAsRead(param, call.method, result); } else if (EMSDKMethod.getUnreadMessageCount.equals(call.method)) { - getUnreadMessageCount(param, EMSDKMethod.getUnreadMessageCount, result); + getUnreadMessageCount(param, call.method, result); } else if (EMSDKMethod.updateChatMessage.equals(call.method)) { - updateChatMessage(param, EMSDKMethod.updateChatMessage, result); + updateChatMessage(param, call.method, result); } else if (EMSDKMethod.downloadAttachment.equals(call.method)) { - downloadAttachment(param, EMSDKMethod.downloadAttachment, result); + downloadAttachment(param, call.method, result); } else if (EMSDKMethod.downloadThumbnail.equals(call.method)) { - downloadThumbnail(param, EMSDKMethod.downloadThumbnail, result); + downloadThumbnail(param, call.method, result); } else if (EMSDKMethod.importMessages.equals(call.method)) { - importMessages(param, EMSDKMethod.importMessages, result); + importMessages(param, call.method, result); } else if (EMSDKMethod.loadAllConversations.equals(call.method)) { - loadAllConversations(param, EMSDKMethod.loadAllConversations, result); + loadAllConversations(param, call.method, result); } else if (EMSDKMethod.getConversationsFromServer.equals(call.method)) { - getConversationsFromServer(param, EMSDKMethod.getConversationsFromServer, result); + getConversationsFromServer(param, call.method, result); } else if (EMSDKMethod.deleteConversation.equals(call.method)) { - deleteConversation(param, EMSDKMethod.deleteConversation, result); + deleteConversation(param, call.method, result); } else if (EMSDKMethod.fetchHistoryMessages.equals(call.method)) { - fetchHistoryMessages(param, EMSDKMethod.fetchHistoryMessages, result); + fetchHistoryMessages(param, call.method, result); } else if (EMSDKMethod.searchChatMsgFromDB.equals(call.method)) { - searchChatMsgFromDB(param, EMSDKMethod.searchChatMsgFromDB, result); + searchChatMsgFromDB(param, call.method, result); } else if (EMSDKMethod.getMessage.equals(call.method)) { - getMessage(param, EMSDKMethod.getMessage, result); + getMessage(param, call.method, result); } else if (EMSDKMethod.asyncFetchGroupAcks.equals(call.method)){ - asyncFetchGroupMessageAckFromServer(param, EMSDKMethod.asyncFetchGroupAcks, result); + asyncFetchGroupMessageAckFromServer(param, call.method, result); } else { super.onMethodCall(call, result); } diff --git a/android/src/main/java/com/easemob/im_flutter_sdk/EMChatRoomManagerWrapper.java b/android/src/main/java/com/easemob/im_flutter_sdk/EMChatRoomManagerWrapper.java index 329041d7..b1158845 100644 --- a/android/src/main/java/com/easemob/im_flutter_sdk/EMChatRoomManagerWrapper.java +++ b/android/src/main/java/com/easemob/im_flutter_sdk/EMChatRoomManagerWrapper.java @@ -31,70 +31,70 @@ public class EMChatRoomManagerWrapper extends EMWrapper implements MethodChannel } @Override - public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) { + public void onMethodCall(MethodCall call, MethodChannel.Result result) { - JSONObject param = (JSONObject) methodCall.arguments; + JSONObject param = (JSONObject) call.arguments; try { - if (EMSDKMethod.joinChatRoom.equals(methodCall.method)) { - joinChatRoom(param, EMSDKMethod.joinChatRoom, result); - } else if (EMSDKMethod.leaveChatRoom.equals(methodCall.method)) { - leaveChatRoom(param, EMSDKMethod.joinChatRoom, result); - } else if (EMSDKMethod.fetchPublicChatRoomsFromServer.equals(methodCall.method)) { - fetchPublicChatRoomsFromServer(param, EMSDKMethod.fetchPublicChatRoomsFromServer, result); - } else if (EMSDKMethod.fetchChatRoomInfoFromServer.equals(methodCall.method)) { - fetchChatRoomInfoFromServer(param, EMSDKMethod.fetchChatRoomInfoFromServer, result); - } else if (EMSDKMethod.getChatRoom.equals(methodCall.method)) { - getChatRoom(param, EMSDKMethod.getChatRoom, result); - } else if (EMSDKMethod.getAllChatRooms.equals(methodCall.method)) { - getAllChatRooms(param, EMSDKMethod.getAllChatRooms, result); - } else if (EMSDKMethod.createChatRoom.equals(methodCall.method)) { - createChatRoom(param, EMSDKMethod.createChatRoom, result); - } else if (EMSDKMethod.destroyChatRoom.equals(methodCall.method)) { - destroyChatRoom(param, EMSDKMethod.destroyChatRoom, result); - } else if (EMSDKMethod.changeChatRoomSubject.equals(methodCall.method)) { - changeChatRoomSubject(param, EMSDKMethod.changeChatRoomSubject, result); - } else if (EMSDKMethod.changeChatRoomDescription.equals(methodCall.method)) { - changeChatRoomDescription(param, EMSDKMethod.changeChatRoomDescription, result); - } else if (EMSDKMethod.fetchChatRoomMembers.equals(methodCall.method)) { - fetchChatRoomMembers(param, EMSDKMethod.fetchChatRoomMembers, result); - } else if (EMSDKMethod.muteChatRoomMembers.equals(methodCall.method)) { - muteChatRoomMembers(param, EMSDKMethod.muteChatRoomMembers, result); - } else if (EMSDKMethod.unMuteChatRoomMembers.equals(methodCall.method)) { - unMuteChatRoomMembers(param, EMSDKMethod.unMuteChatRoomMembers, result); - } else if (EMSDKMethod.changeChatRoomOwner.equals(methodCall.method)) { - changeChatRoomOwner(param, EMSDKMethod.changeChatRoomOwner, result); - } else if (EMSDKMethod.addChatRoomAdmin.equals(methodCall.method)) { - addChatRoomAdmin(param, EMSDKMethod.addChatRoomAdmin, result); - } else if (EMSDKMethod.removeChatRoomAdmin.equals(methodCall.method)) { - removeChatRoomAdmin(param, EMSDKMethod.removeChatRoomAdmin, result); - } else if (EMSDKMethod.fetchChatRoomMuteList.equals(methodCall.method)) { - fetchChatRoomMuteList(param, EMSDKMethod.fetchChatRoomMuteList, result); - } else if (EMSDKMethod.removeChatRoomMembers.equals(methodCall.method)) { - removeChatRoomMembers(param, EMSDKMethod.removeChatRoomMembers, result); - } else if (EMSDKMethod.blockChatRoomMembers.equals(methodCall.method)) { - blockChatRoomMembers(param, EMSDKMethod.blockChatRoomMembers, result); - } else if (EMSDKMethod.unBlockChatRoomMembers.equals(methodCall.method)) { - unBlockChatRoomMembers(param, EMSDKMethod.unBlockChatRoomMembers, result); - } else if (EMSDKMethod.fetchChatRoomBlockList.equals(methodCall.method)) { - fetchChatRoomBlockList(param, EMSDKMethod.fetchChatRoomBlockList, result); - } else if (EMSDKMethod.updateChatRoomAnnouncement.equals(methodCall.method)) { - updateChatRoomAnnouncement(param, EMSDKMethod.updateChatRoomAnnouncement, result); - } else if (EMSDKMethod.fetchChatRoomAnnouncement.equals(methodCall.method)) { - fetchChatRoomAnnouncement(param, EMSDKMethod.fetchChatRoomAnnouncement, result); - } else if (EMSDKMethod.addMembersToChatRoomWhiteList.equals(methodCall.method)) { - addMembersToChatRoomWhiteList(param, EMSDKMethod.addMembersToChatRoomWhiteList, result); - } else if (EMSDKMethod.removeMembersFromChatRoomWhiteList.equals(methodCall.method)) { - removeMembersFromChatRoomWhiteList(param, EMSDKMethod.removeMembersFromChatRoomWhiteList, result); - } else if (EMSDKMethod.isMemberInChatRoomWhiteListFromServer.equals(methodCall.method)) { - isMemberInChatRoomWhiteListFromServer(param, EMSDKMethod.isMemberInChatRoomWhiteListFromServer, result); - } else if (EMSDKMethod.fetchChatRoomWhiteListFromServer.equals(methodCall.method)) { - fetchChatRoomWhiteListFromServer(param, EMSDKMethod.fetchChatRoomWhiteListFromServer, result); - } else if (EMSDKMethod.muteAllChatRoomMembers.equals(methodCall.method)) { - muteAllChatRoomsMembers(param, EMSDKMethod.fetchChatRoomWhiteListFromServer, result); - } else if (EMSDKMethod.unMuteAllChatRoomMembers.equals(methodCall.method)) { - unMuteAllChatRoomsMembers(param, EMSDKMethod.fetchChatRoomWhiteListFromServer, result); + if (EMSDKMethod.joinChatRoom.equals(call.method)) { + joinChatRoom(param, call.method, result); + } else if (EMSDKMethod.leaveChatRoom.equals(call.method)) { + leaveChatRoom(param, call.method, result); + } else if (EMSDKMethod.fetchPublicChatRoomsFromServer.equals(call.method)) { + fetchPublicChatRoomsFromServer(param, call.method, result); + } else if (EMSDKMethod.fetchChatRoomInfoFromServer.equals(call.method)) { + fetchChatRoomInfoFromServer(param, call.method, result); + } else if (EMSDKMethod.getChatRoom.equals(call.method)) { + getChatRoom(param, call.method, result); + } else if (EMSDKMethod.getAllChatRooms.equals(call.method)) { + getAllChatRooms(param, call.method, result); + } else if (EMSDKMethod.createChatRoom.equals(call.method)) { + createChatRoom(param, call.method, result); + } else if (EMSDKMethod.destroyChatRoom.equals(call.method)) { + destroyChatRoom(param, call.method, result); + } else if (EMSDKMethod.changeChatRoomSubject.equals(call.method)) { + changeChatRoomSubject(param, call.method, result); + } else if (EMSDKMethod.changeChatRoomDescription.equals(call.method)) { + changeChatRoomDescription(param, call.method, result); + } else if (EMSDKMethod.fetchChatRoomMembers.equals(call.method)) { + fetchChatRoomMembers(param, call.method, result); + } else if (EMSDKMethod.muteChatRoomMembers.equals(call.method)) { + muteChatRoomMembers(param, call.method, result); + } else if (EMSDKMethod.unMuteChatRoomMembers.equals(call.method)) { + unMuteChatRoomMembers(param, call.method, result); + } else if (EMSDKMethod.changeChatRoomOwner.equals(call.method)) { + changeChatRoomOwner(param, call.method, result); + } else if (EMSDKMethod.addChatRoomAdmin.equals(call.method)) { + addChatRoomAdmin(param, call.method, result); + } else if (EMSDKMethod.removeChatRoomAdmin.equals(call.method)) { + removeChatRoomAdmin(param, call.method, result); + } else if (EMSDKMethod.fetchChatRoomMuteList.equals(call.method)) { + fetchChatRoomMuteList(param, call.method, result); + } else if (EMSDKMethod.removeChatRoomMembers.equals(call.method)) { + removeChatRoomMembers(param, call.method, result); + } else if (EMSDKMethod.blockChatRoomMembers.equals(call.method)) { + blockChatRoomMembers(param, call.method, result); + } else if (EMSDKMethod.unBlockChatRoomMembers.equals(call.method)) { + unBlockChatRoomMembers(param, call.method, result); + } else if (EMSDKMethod.fetchChatRoomBlockList.equals(call.method)) { + fetchChatRoomBlockList(param, call.method, result); + } else if (EMSDKMethod.updateChatRoomAnnouncement.equals(call.method)) { + updateChatRoomAnnouncement(param, call.method, result); + } else if (EMSDKMethod.fetchChatRoomAnnouncement.equals(call.method)) { + fetchChatRoomAnnouncement(param, call.method, result); + } else if (EMSDKMethod.addMembersToChatRoomWhiteList.equals(call.method)) { + addMembersToChatRoomWhiteList(param, call.method, result); + } else if (EMSDKMethod.removeMembersFromChatRoomWhiteList.equals(call.method)) { + removeMembersFromChatRoomWhiteList(param, call.method, result); + } else if (EMSDKMethod.isMemberInChatRoomWhiteListFromServer.equals(call.method)) { + isMemberInChatRoomWhiteListFromServer(param, call.method, result); + } else if (EMSDKMethod.fetchChatRoomWhiteListFromServer.equals(call.method)) { + fetchChatRoomWhiteListFromServer(param, call.method, result); + } else if (EMSDKMethod.muteAllChatRoomMembers.equals(call.method)) { + muteAllChatRoomsMembers(param, call.method, result); + } else if (EMSDKMethod.unMuteAllChatRoomMembers.equals(call.method)) { + unMuteAllChatRoomsMembers(param, call.method, result); } else { - super.onMethodCall(methodCall, result); + super.onMethodCall(call, result); } } catch (JSONException ignored) { 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 dfbd2bc1..6f40a865 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 @@ -53,59 +53,59 @@ public void onMethodCall(MethodCall call, @NonNull Result result) { JSONObject param = (JSONObject)call.arguments; try { if (EMSDKMethod.init.equals(call.method)) { - init(param, EMSDKMethod.init, result); + init(param, call.method, result); } else if (EMSDKMethod.createAccount.equals(call.method)) { - createAccount(param, EMSDKMethod.createAccount, result); + createAccount(param, call.method, result); } else if (EMSDKMethod.login.equals(call.method)) { - login(param, EMSDKMethod.login, result); + login(param, call.method, result); } else if (EMSDKMethod.logout.equals(call.method)) { - logout(param, EMSDKMethod.logout, result); + logout(param, call.method, result); } else if (EMSDKMethod.changeAppKey.equals(call.method)) { - changeAppKey(param, EMSDKMethod.changeAppKey, result); + changeAppKey(param, call.method, result); } else if (EMSDKMethod.updateCurrentUserNick.equals(call.method)) { - updateCurrentUserNick(param, EMSDKMethod.updateCurrentUserNick, result); + updateCurrentUserNick(param, call.method, result); } else if (EMSDKMethod.uploadLog.equals(call.method)) { - uploadLog(param, EMSDKMethod.uploadLog, result); + uploadLog(param, call.method, result); } else if (EMSDKMethod.compressLogs.equals(call.method)) { - compressLogs(param, EMSDKMethod.compressLogs, result); + compressLogs(param, call.method, result); } else if (EMSDKMethod.getLoggedInDevicesFromServer.equals(call.method)) { - getLoggedInDevicesFromServer(param, EMSDKMethod.getLoggedInDevicesFromServer, result); + getLoggedInDevicesFromServer(param, call.method, result); } else if (EMSDKMethod.kickDevice.equals(call.method)) { - kickDevice(param, EMSDKMethod.kickDevice, result); + kickDevice(param, call.method, result); } else if (EMSDKMethod.kickAllDevices.equals(call.method)) { - kickAllDevices(param, EMSDKMethod.kickAllDevices, result); + kickAllDevices(param, call.method, result); } else if (EMSDKMethod.isLoggedInBefore.equals(call.method)) { - isLoggedInBefore(param, EMSDKMethod.isLoggedInBefore, result); + isLoggedInBefore(param, call.method, result); } else if (EMSDKMethod.getCurrentUser.equals(call.method)) { - getCurrentUser(param, EMSDKMethod.getCurrentUser, result); + getCurrentUser(param, call.method, result); } else if (EMSDKMethod.getToken.equals(call.method)) { - getToken(param, EMSDKMethod.getToken, result); + getToken(param, call.method, result); } else if (EMSDKMethod.isConnected.equals(call.method)) { isConnected(param, call.method, result); diff --git a/android/src/main/java/com/easemob/im_flutter_sdk/EMContactManagerWrapper.java b/android/src/main/java/com/easemob/im_flutter_sdk/EMContactManagerWrapper.java index 0da7949c..521b74e8 100644 --- a/android/src/main/java/com/easemob/im_flutter_sdk/EMContactManagerWrapper.java +++ b/android/src/main/java/com/easemob/im_flutter_sdk/EMContactManagerWrapper.java @@ -30,27 +30,27 @@ public void onMethodCall(MethodCall call, Result result) { JSONObject param = (JSONObject) call.arguments; try { if (EMSDKMethod.addContact.equals(call.method)) { - addContact(param, EMSDKMethod.addContact, result); + addContact(param, call.method, result); } else if (EMSDKMethod.deleteContact.equals(call.method)) { - deleteContact(param, EMSDKMethod.deleteContact, result); + deleteContact(param, call.method, result); } else if (EMSDKMethod.getAllContactsFromServer.equals(call.method)) { - getAllContactsFromServer(param, EMSDKMethod.getAllContactsFromServer, result); + getAllContactsFromServer(param, call.method, result); } else if (EMSDKMethod.getAllContactsFromDB.equals(call.method)) { - getAllContactsFromDB(param, EMSDKMethod.getAllContactsFromDB, result); + getAllContactsFromDB(param, call.method, result); } else if (EMSDKMethod.addUserToBlockList.equals(call.method)) { - addUserToBlockList(param, EMSDKMethod.addUserToBlockList, result); + addUserToBlockList(param, call.method, result); } else if (EMSDKMethod.removeUserFromBlockList.equals(call.method)) { - removeUserFromBlockList(param, EMSDKMethod.removeUserFromBlockList, result); + removeUserFromBlockList(param, call.method, result); } else if (EMSDKMethod.getBlockListFromServer.equals(call.method)) { - getBlockListFromServer(param, EMSDKMethod.getBlockListFromServer, result); + getBlockListFromServer(param, call.method, result); } else if (EMSDKMethod.getBlockListFromDB.equals(call.method)) { - getBlockListFromDB(param, EMSDKMethod.getBlockListFromDB, result); + getBlockListFromDB(param, call.method, result); } else if (EMSDKMethod.acceptInvitation.equals(call.method)) { - acceptInvitation(param, EMSDKMethod.acceptInvitation, result); + acceptInvitation(param, call.method, result); } else if (EMSDKMethod.declineInvitation.equals(call.method)) { - declineInvitation(param, EMSDKMethod.declineInvitation, result); + declineInvitation(param, call.method, result); } else if (EMSDKMethod.getSelfIdsOnOtherPlatform.equals(call.method)) { - getSelfIdsOnOtherPlatform(param, EMSDKMethod.getSelfIdsOnOtherPlatform, result); + getSelfIdsOnOtherPlatform(param, call.method, result); } else { super.onMethodCall(call, result); } diff --git a/android/src/main/java/com/easemob/im_flutter_sdk/EMConversationWrapper.java b/android/src/main/java/com/easemob/im_flutter_sdk/EMConversationWrapper.java index 0c8ea060..87f03645 100644 --- a/android/src/main/java/com/easemob/im_flutter_sdk/EMConversationWrapper.java +++ b/android/src/main/java/com/easemob/im_flutter_sdk/EMConversationWrapper.java @@ -33,56 +33,56 @@ public void onMethodCall(MethodCall call, Result result) { try { if (EMSDKMethod.getUnreadMsgCount.equals(call.method)) { - getUnreadMsgCount(param, EMSDKMethod.getUnreadMsgCount, result); + getUnreadMsgCount(param, call.method, result); } else if (EMSDKMethod.markAllMessagesAsRead.equals(call.method)) { - markAllMessagesAsRead(param, EMSDKMethod.markAllMessagesAsRead, result); + markAllMessagesAsRead(param, call.method, result); } else if (EMSDKMethod.markMessageAsRead.equals(call.method)) { - markMessageAsRead(param, EMSDKMethod.markMessageAsRead, result); + markMessageAsRead(param, call.method, result); } else if (EMSDKMethod.syncConversationExt.equals(call.method)){ - syncConversationExt(param, EMSDKMethod.syncConversationExt, result); + syncConversationExt(param, call.method, result); } else if (EMSDKMethod.syncConversationName.equals(call.method)){ - syncConversationName(param, EMSDKMethod.syncConversationName, result); + syncConversationName(param, call.method, result); } else if (EMSDKMethod.removeMessage.equals(call.method)) { - removeMessage(param, EMSDKMethod.removeMessage, result); + removeMessage(param, call.method, result); } else if (EMSDKMethod.getLatestMessage.equals(call.method)) { - getLatestMessage(param, EMSDKMethod.getLatestMessage, result); + getLatestMessage(param, call.method, result); } else if (EMSDKMethod.getLatestMessageFromOthers.equals(call.method)) { - getLatestMessageFromOthers(param, EMSDKMethod.getLatestMessageFromOthers, result); + getLatestMessageFromOthers(param, call.method, result); } else if (EMSDKMethod.clearAllMessages.equals(call.method)) { - clearAllMessages(param, EMSDKMethod.clearAllMessages, result); + clearAllMessages(param, call.method, result); } else if (EMSDKMethod.insertMessage.equals((call.method))) { - insertMessage(param, EMSDKMethod.insertMessage, result); + insertMessage(param, call.method, result); } else if (EMSDKMethod.appendMessage.equals(call.method)) { - appendMessage(param, EMSDKMethod.appendMessage, result); + appendMessage(param, call.method, result); } else if (EMSDKMethod.updateConversationMessage.equals(call.method)) { - updateConversationMessage(param, EMSDKMethod.updateConversationMessage, result); + updateConversationMessage(param, call.method, result); } else if (EMSDKMethod.loadMsgWithId.equals(call.method)) { - loadMsgWithId(param, EMSDKMethod.loadMsgWithId, result); + loadMsgWithId(param, call.method, result); } else if (EMSDKMethod.loadMsgWithStartId.equals(call.method)) { - loadMsgWithStartId(param, EMSDKMethod.loadMsgWithStartId, result); + loadMsgWithStartId(param, call.method, result); } else if (EMSDKMethod.loadMsgWithKeywords.equals(call.method)) { - loadMsgWithKeywords(param, EMSDKMethod.loadMsgWithKeywords, result); + loadMsgWithKeywords(param, call.method, result); } else if (EMSDKMethod.loadMsgWithMsgType.equals(call.method)) { - loadMsgWithMsgType(param, EMSDKMethod.loadMsgWithMsgType, result); + loadMsgWithMsgType(param, call.method, result); } else if (EMSDKMethod.loadMsgWithTime.equals(call.method)) { - loadMsgWithTime(param, EMSDKMethod.loadMsgWithTime, result); + loadMsgWithTime(param, call.method, result); } else diff --git a/android/src/main/java/com/easemob/im_flutter_sdk/EMGroupManagerWrapper.java b/android/src/main/java/com/easemob/im_flutter_sdk/EMGroupManagerWrapper.java index 2376a823..add90788 100644 --- a/android/src/main/java/com/easemob/im_flutter_sdk/EMGroupManagerWrapper.java +++ b/android/src/main/java/com/easemob/im_flutter_sdk/EMGroupManagerWrapper.java @@ -42,99 +42,97 @@ public void onMethodCall(MethodCall call, MethodChannel.Result result) { JSONObject param = (JSONObject) call.arguments; try { if (EMSDKMethod.getGroupWithId.equals(call.method)) { - getGroupWithId(param, EMSDKMethod.getGroupWithId, result); + getGroupWithId(param, call.method, result); } else if (EMSDKMethod.getJoinedGroups.equals(call.method)) { - getJoinedGroups(param, EMSDKMethod.getJoinedGroups, result); + getJoinedGroups(param, call.method, result); } else if (EMSDKMethod.getGroupsWithoutPushNotification.equals(call.method)) { - getGroupsWithoutPushNotification(param, EMSDKMethod.getGroupsWithoutPushNotification, result); + getGroupsWithoutPushNotification(param, call.method, result); } else if (EMSDKMethod.getJoinedGroupsFromServer.equals(call.method)) { - getJoinedGroupsFromServer(param, EMSDKMethod.getJoinedGroupsFromServer, result); + getJoinedGroupsFromServer(param, call.method, result); } else if (EMSDKMethod.getPublicGroupsFromServer.equals(call.method)) { - getPublicGroupsFromServer(param, EMSDKMethod.getPublicGroupsFromServer, result); + getPublicGroupsFromServer(param, call.method, result); } else if (EMSDKMethod.createGroup.equals(call.method)) { - createGroup(param, EMSDKMethod.createGroup, result); + createGroup(param, call.method, result); } else if (EMSDKMethod.getGroupSpecificationFromServer.equals(call.method)) { - getGroupSpecificationFromServer(param, EMSDKMethod.getGroupSpecificationFromServer, result); + getGroupSpecificationFromServer(param, call.method, result); } else if (EMSDKMethod.getGroupMemberListFromServer.equals(call.method)) { - getGroupMemberListFromServer(param, EMSDKMethod.getGroupMemberListFromServer, result); + getGroupMemberListFromServer(param, call.method, result); } else if (EMSDKMethod.getGroupMuteListFromServer.equals(call.method)) { - getGroupMuteListFromServer(param, EMSDKMethod.getGroupMuteListFromServer, result); - } else if (EMSDKMethod.getGroupBlockListFromServer.equals(call.method)) { - getGroupBlockListFromServer(param, EMSDKMethod.getGroupBlockListFromServer, result); + getGroupMuteListFromServer(param, call.method, result); } else if (EMSDKMethod.getGroupWhiteListFromServer.equals(call.method)) { - getGroupWhiteListFromServer(param, EMSDKMethod.getGroupWhiteListFromServer, result); + getGroupWhiteListFromServer(param, call.method, result); } else if (EMSDKMethod.isMemberInWhiteListFromServer.equals(call.method)) { - isMemberInWhiteListFromServer(param, EMSDKMethod.isMemberInWhiteListFromServer, result); + isMemberInWhiteListFromServer(param, call.method, result); } else if (EMSDKMethod.getGroupFileListFromServer.equals(call.method)) { - getGroupFileListFromServer(param, EMSDKMethod.getGroupFileListFromServer, result); + getGroupFileListFromServer(param, call.method, result); } else if (EMSDKMethod.getGroupAnnouncementFromServer.equals(call.method)) { - getGroupAnnouncementFromServer(param, EMSDKMethod.getGroupAnnouncementFromServer, result); + getGroupAnnouncementFromServer(param, call.method, result); } else if (EMSDKMethod.getGroupBlockListFromServer.equals(call.method)) { - getGroupBlockListFromServer(param, EMSDKMethod.getGroupBlockListFromServer, result); + getGroupBlockListFromServer(param, call.method, result); } else if (EMSDKMethod.addMembers.equals(call.method)) { - addMembers(param, EMSDKMethod.addMembers, result); + addMembers(param, call.method, result); } else if (EMSDKMethod.inviterUser.equals(call.method)){ - inviterUser(param, EMSDKMethod.inviterUser, result); + inviterUser(param, call.method, result); } else if (EMSDKMethod.removeMembers.equals(call.method)) { - removeMembers(param, EMSDKMethod.removeMembers, result); + removeMembers(param, call.method, result); } else if (EMSDKMethod.blockMembers.equals(call.method)) { - blockMembers(param, EMSDKMethod.blockMembers, result); + blockMembers(param, call.method, result); } else if (EMSDKMethod.unblockMembers.equals(call.method)) { - unblockMembers(param, EMSDKMethod.unblockMembers, result); + unblockMembers(param, call.method, result); } else if (EMSDKMethod.updateGroupSubject.equals(call.method)) { - updateGroupSubject(param, EMSDKMethod.updateGroupSubject, result); + updateGroupSubject(param, call.method, result); } else if (EMSDKMethod.updateDescription.equals(call.method)) { - updateDescription(param, EMSDKMethod.updateDescription, result); + updateDescription(param, call.method, result); } else if (EMSDKMethod.leaveGroup.equals(call.method)) { - leaveGroup(param, EMSDKMethod.leaveGroup, result); + leaveGroup(param, call.method, result); } else if (EMSDKMethod.destroyGroup.equals(call.method)) { - destroyGroup(param, EMSDKMethod.destroyGroup, result); + destroyGroup(param, call.method, result); } else if (EMSDKMethod.blockGroup.equals(call.method)) { - blockGroup(param, EMSDKMethod.blockGroup, result); + blockGroup(param, call.method, result); } else if (EMSDKMethod.unblockGroup.equals(call.method)) { - unblockGroup(param, EMSDKMethod.unblockGroup, result); + unblockGroup(param, call.method, result); } else if (EMSDKMethod.updateGroupOwner.equals(call.method)) { - updateGroupOwner(param, EMSDKMethod.updateGroupOwner, result); + updateGroupOwner(param, call.method, result); } else if (EMSDKMethod.addAdmin.equals(call.method)) { - addAdmin(param, EMSDKMethod.addAdmin, result); + addAdmin(param, call.method, result); } else if (EMSDKMethod.removeAdmin.equals(call.method)) { - removeAdmin(param, EMSDKMethod.removeAdmin, result); + removeAdmin(param, call.method, result); } else if (EMSDKMethod.muteMembers.equals(call.method)) { - muteMembers(param, EMSDKMethod.muteMembers, result); + muteMembers(param, call.method, result); } else if (EMSDKMethod.unMuteMembers.equals(call.method)) { - unMuteMembers(param, EMSDKMethod.unMuteMembers, result); + unMuteMembers(param, call.method, result); } else if (EMSDKMethod.muteAllMembers.equals(call.method)) { - muteAllMembers(param, EMSDKMethod.muteAllMembers, result); + muteAllMembers(param, call.method, result); } else if (EMSDKMethod.unMuteAllMembers.equals(call.method)) { - unMuteAllMembers(param, EMSDKMethod.unMuteAllMembers, result); + unMuteAllMembers(param, call.method, result); } else if (EMSDKMethod.addWhiteList.equals(call.method)) { - addWhiteList(param, EMSDKMethod.addWhiteList, result); + addWhiteList(param, call.method, result); } else if (EMSDKMethod.removeWhiteList.equals(call.method)) { - removeWhiteList(param, EMSDKMethod.removeWhiteList, result); + removeWhiteList(param, call.method, result); } else if (EMSDKMethod.uploadGroupSharedFile.equals(call.method)) { - uploadGroupSharedFile(param, EMSDKMethod.uploadGroupSharedFile, result); + uploadGroupSharedFile(param, call.method, result); } else if (EMSDKMethod.downloadGroupSharedFile.equals(call.method)) { - downloadGroupSharedFile(param, EMSDKMethod.downloadGroupSharedFile, result); + downloadGroupSharedFile(param, call.method, result); } else if (EMSDKMethod.removeGroupSharedFile.equals(call.method)) { - removeGroupSharedFile(param, EMSDKMethod.removeGroupSharedFile, result); + removeGroupSharedFile(param, call.method, result); } else if (EMSDKMethod.updateGroupAnnouncement.equals(call.method)) { - updateGroupAnnouncement(param, EMSDKMethod.updateGroupExt, result); + updateGroupAnnouncement(param, call.method, result); } else if (EMSDKMethod.updateGroupExt.equals(call.method)) { - updateGroupExt(param, EMSDKMethod.updateGroupExt, result); + updateGroupExt(param, call.method, result); } else if (EMSDKMethod.joinPublicGroup.equals(call.method)) { - joinPublicGroup(param, EMSDKMethod.joinPublicGroup, result); + joinPublicGroup(param, call.method, result); } else if (EMSDKMethod.requestToJoinPublicGroup.equals(call.method)) { - requestToJoinPublicGroup(param, EMSDKMethod.requestToJoinPublicGroup, result); + requestToJoinPublicGroup(param, call.method, result); } else if (EMSDKMethod.acceptJoinApplication.equals(call.method)) { - acceptJoinApplication(param, EMSDKMethod.acceptJoinApplication, result); + acceptJoinApplication(param, call.method, result); } else if (EMSDKMethod.declineJoinApplication.equals(call.method)) { - declineJoinApplication(param, EMSDKMethod.declineJoinApplication, result); + declineJoinApplication(param, call.method, result); } else if (EMSDKMethod.acceptInvitationFromGroup.equals(call.method)) { - acceptInvitationFromGroup(param, EMSDKMethod.acceptInvitationFromGroup, result); + acceptInvitationFromGroup(param, call.method, result); } else if (EMSDKMethod.declineInvitationFromGroup.equals(call.method)) { - declineInvitationFromGroup(param, EMSDKMethod.declineInvitationFromGroup, result); + declineInvitationFromGroup(param, call.method, result); } else if (EMSDKMethod.ignoreGroupPush.equals(call.method)) { - ignoreGroupPush(param, EMSDKMethod.ignoreGroupPush, result); + ignoreGroupPush(param, call.method, result); } else { super.onMethodCall(call, result); } diff --git a/android/src/main/java/com/easemob/im_flutter_sdk/EMHelper.java b/android/src/main/java/com/easemob/im_flutter_sdk/EMHelper.java index 7af0212a..9d7511a7 100644 --- a/android/src/main/java/com/easemob/im_flutter_sdk/EMHelper.java +++ b/android/src/main/java/com/easemob/im_flutter_sdk/EMHelper.java @@ -157,7 +157,7 @@ static Map toJson(EMGroup group) { data.put("adminList", group.getAdminList()); data.put("blockList", group.getBlackList()); data.put("muteList", group.getMuteList()); - data.put("sharedFileList", group.getShareFileList()); + if (group.getGroupId() != null && EMClient.getInstance().pushManager().getNoPushGroups() != null) { data.put("noticeEnable", !EMClient.getInstance().pushManager().getNoPushGroups().contains(group.getGroupId())); diff --git a/android/src/main/java/com/easemob/im_flutter_sdk/EMPushManagerWrapper.java b/android/src/main/java/com/easemob/im_flutter_sdk/EMPushManagerWrapper.java index 8d5dcbda..7614fff6 100644 --- a/android/src/main/java/com/easemob/im_flutter_sdk/EMPushManagerWrapper.java +++ b/android/src/main/java/com/easemob/im_flutter_sdk/EMPushManagerWrapper.java @@ -32,31 +32,31 @@ public void onMethodCall(MethodCall call, Result result) { JSONObject param = (JSONObject)call.arguments; try { if (EMSDKMethod.getImPushConfig.equals(call.method)) { - getImPushConfig(param, EMSDKMethod.getImPushConfig, result); + getImPushConfig(param, call.method, result); } else if(EMSDKMethod.getImPushConfigFromServer.equals(call.method)){ - getImPushConfigFromServer(param, EMSDKMethod.getImPushConfigFromServer, result); + getImPushConfigFromServer(param, call.method, result); } else if(EMSDKMethod.updatePushNickname.equals(call.method)){ - updatePushNickname(param, EMSDKMethod.updatePushNickname, result); + updatePushNickname(param, call.method, result); } else if(EMSDKMethod.imPushNoDisturb.equals(call.method)){ - imPushNoDisturb(param, EMSDKMethod.imPushNoDisturb, result); + imPushNoDisturb(param, call.method, result); } else if(EMSDKMethod.updateImPushStyle.equals(call.method)){ - updateImPushStyle(param, EMSDKMethod.updateImPushStyle, result); + updateImPushStyle(param, call.method, result); } else if(EMSDKMethod.updateGroupPushService.equals(call.method)){ - updateGroupPushService(param, EMSDKMethod.updateGroupPushService, result); + updateGroupPushService(param, call.method, result); } else if(EMSDKMethod.getNoDisturbGroups.equals(call.method)){ - getNoDisturbGroups(param, EMSDKMethod.getNoDisturbGroups, result); + getNoDisturbGroups(param, call.method, result); } else if(EMSDKMethod.updateHMSPushToken.equals(call.method)){ - updateHMSPushToken(param, EMSDKMethod.updateHMSPushToken, result); + updateHMSPushToken(param, call.method, result); } else if(EMSDKMethod.updateFCMPushToken.equals(call.method)){ - updateFCMPushToken(param, EMSDKMethod.updateFCMPushToken, result); + updateFCMPushToken(param, call.method, result); } else { super.onMethodCall(call, result); @@ -119,7 +119,7 @@ private void updateImPushStyle(JSONObject params, String channelName, Result re private void updateGroupPushService(JSONObject params, String channelName, Result result) throws JSONException { String groupId = params.getString("group_id"); - boolean enablePush = params.getBoolean("enablePush"); + boolean enablePush = params.getBoolean("noDisturb"); List groupList = new ArrayList<>(); groupList.add(groupId); asyncRunnable(()-> { diff --git a/android/src/main/java/com/easemob/im_flutter_sdk/EMUserInfoManagerWrapper.java b/android/src/main/java/com/easemob/im_flutter_sdk/EMUserInfoManagerWrapper.java index ad7570ee..f2b24db4 100644 --- a/android/src/main/java/com/easemob/im_flutter_sdk/EMUserInfoManagerWrapper.java +++ b/android/src/main/java/com/easemob/im_flutter_sdk/EMUserInfoManagerWrapper.java @@ -37,13 +37,13 @@ public void onMethodCall(MethodCall call, Result result) { JSONObject param = (JSONObject) call.arguments; try { if (EMSDKMethod.updateOwnUserInfo.equals(call.method)) { - updateOwnUserInfo(param, EMSDKMethod.updateOwnUserInfo, result); + updateOwnUserInfo(param, call.method, result); } else if (EMSDKMethod.updateOwnUserInfoWithType.equals(call.method)) { - updateOwnUserInfoWithType(param, EMSDKMethod.updateOwnUserInfoWithType, result); + updateOwnUserInfoWithType(param, call.method, result); }else if (EMSDKMethod.fetchUserInfoById.equals(call.method)) { - fetchUserInfoByUserId(param, EMSDKMethod.fetchUserInfoById, result); + fetchUserInfoByUserId(param, call.method, result); }else if (EMSDKMethod.fetchUserInfoByIdWithType.equals(call.method)) { - fetchUserInfoByIdWithType(param, EMSDKMethod.fetchUserInfoByIdWithType, result); + fetchUserInfoByIdWithType(param, call.method, result); } else { super.onMethodCall(call, result); } diff --git a/example/lib/main.dart b/example/lib/main.dart index b5caa6ce..966dfb52 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -22,13 +22,17 @@ void main() { SystemUiOverlayStyle uiStyle = SystemUiOverlayStyle.light; SystemChrome.setSystemUIOverlayStyle(uiStyle); - EMPushConfig config = EMPushConfig()..enableAPNs('EaseIM_APNS_Product'); + initSDK(); + return runApp(EaseIMDemo()); +} + +void initSDK() async { var options = EMOptions(appKey: 'easemob-demo#easeim'); options.debugModel = true; + options.enableAPNs("EaseIM_APNS_Product"); - options.pushConfig = config; - EMClient.getInstance.init(options).then((value) => null); - return runApp(EaseIMDemo()); + await EMClient.getInstance.init(options); + debugPrint("has init"); } class EaseIMDemo extends StatelessWidget { diff --git a/example/lib/pages/chat/chat_page.dart b/example/lib/pages/chat/chat_page.dart index 6564d3bd..8929f8af 100644 --- a/example/lib/pages/chat/chat_page.dart +++ b/example/lib/pages/chat/chat_page.dart @@ -53,6 +53,7 @@ class _ChatPageState extends State @override void initState() { super.initState(); + items = [ ChatMoreViewItem( 'images/chat_input_more_photo.png', '相册', _moreViewPhotoBtnOnTap), diff --git a/example/lib/pages/conversations/conversation_item.dart b/example/lib/pages/conversations/conversation_item.dart index f1cc5e59..17d6523b 100644 --- a/example/lib/pages/conversations/conversation_item.dart +++ b/example/lib/pages/conversations/conversation_item.dart @@ -163,7 +163,7 @@ class _ConversationItemState extends State { /// 未读数 int _unreadCount() { - return this.widget.conversation.unreadCount ?? 0; + return this.widget.conversation.unreadCount; } /// 消息时间 diff --git a/example/lib/pages/conversations/conversations_page.dart b/example/lib/pages/conversations/conversations_page.dart index ea2b3f4d..2bdb313c 100644 --- a/example/lib/pages/conversations/conversations_page.dart +++ b/example/lib/pages/conversations/conversations_page.dart @@ -160,7 +160,7 @@ class ConversationPageState extends State _refreshController.refreshCompleted(); int count = 0; for (var conversation in _conversationsList) { - count += conversation.unreadCount ?? 0; + count += conversation.unreadCount; } widget.updateCount(count); } on Error { diff --git a/ios/Classes/EMChatManagerWrapper.m b/ios/Classes/EMChatManagerWrapper.m index 8eaebd62..819d7c8c 100644 --- a/ios/Classes/EMChatManagerWrapper.m +++ b/ios/Classes/EMChatManagerWrapper.m @@ -43,88 +43,88 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { if ([EMMethodKeySendMessage isEqualToString:call.method]) { [self sendMessage:call.arguments - channelName:EMMethodKeySendMessage + channelName:call.method result:result]; } else if ([EMMethodKeyResendMessage isEqualToString:call.method]) { [self resendMessage:call.arguments - channelName:EMMethodKeyResendMessage + channelName:call.method result:result]; } else if ([EMMethodKeyAckMessageRead isEqualToString:call.method]) { [self ackMessageRead:call.arguments - channelName:EMMethodKeyAckMessageRead + channelName:call.method result:result]; } else if ([EMMethodKeyAckGroupMessageRead isEqualToString:call.method]) { [self ackMessageRead:call.arguments - channelName:EMMethodKeyAckMessageRead + channelName:call.method result:result]; } else if ([EMMethodKeyAckConversationRead isEqualToString:call.method]) { [self ackConversationRead:call.arguments - channelName:EMMethodKeyAckConversationRead + channelName:call.method result:result]; } else if ([EMMethodKeyRecallMessage isEqualToString:call.method]) { [self recallMessage:call.arguments - channelName:EMMethodKeyRecallMessage + channelName:call.method result:result]; } else if ([EMMethodKeyGetConversation isEqualToString:call.method]) { [self getConversation:call.arguments - channelName:EMMethodKeyGetConversation + channelName:call.method result:result]; } else if ([EMMethodKeyGetMessage isEqualToString:call.method]) { [self getMessageWithMessageId:call.arguments - channelName:EMMethodKeyGetMessage + channelName:call.method result:result]; } else if ([EMMethodKeyMarkAllChatMsgAsRead isEqualToString:call.method]) { [self markAllMessagesAsRead:call.arguments - channelName:EMMethodKeyMarkAllChatMsgAsRead + channelName:call.method result:result]; } else if ([EMMethodKeyGetUnreadMessageCount isEqualToString:call.method]) { [self getUnreadMessageCount:call.arguments - channelName:EMMethodKeyGetUnreadMessageCount + channelName:call.method result:result]; } else if ([EMMethodKeyUpdateChatMessage isEqualToString:call.method]) { [self updateChatMessage:call.arguments - channelName:EMMethodKeyUpdateChatMessage + channelName:call.method result:result]; } else if ([EMMethodKeyDownloadAttachment isEqualToString:call.method]) { [self downloadAttachment:call.arguments - channelName:EMMethodKeyDownloadAttachment + channelName:call.method result:result]; } else if ([EMMethodKeyDownloadThumbnail isEqualToString:call.method]) { [self downloadThumbnail:call.arguments - channelName:EMMethodKeyDownloadThumbnail + channelName:call.method result:result]; } else if ([EMMethodKeyImportMessages isEqualToString:call.method]) { [self importMessages:call.arguments - channelName:EMMethodKeyImportMessages + channelName:call.method result:result]; } else if ([EMMethodKeyLoadAllConversations isEqualToString:call.method]) { [self loadAllConversations:call.arguments - channelName:EMMethodKeyLoadAllConversations + channelName:call.method result:result]; } else if ([EMMethodKeyGetConversationsFromServer isEqualToString:call.method]) { [self getConversationsFromServer:call.arguments - channelName:EMMethodKeyGetConversationsFromServer + channelName:call.method result:result]; } else if ([EMMethodKeyDeleteConversation isEqualToString:call.method]) { [self deleteConversation:call.arguments - channelName:EMMethodKeyDeleteConversation + channelName:call.method result:result]; } else if ([EMMethodKeyFetchHistoryMessages isEqualToString:call.method]) { [self fetchHistoryMessages:call.arguments - channelName:EMMethodKeyFetchHistoryMessages + channelName:call.method result:result]; } else if ([EMMethodKeySearchChatMsgFromDB isEqualToString:call.method]) { [self searchChatMsgFromDB:call.arguments - channelName:EMMethodKeySearchChatMsgFromDB + channelName:call.method result:result]; } else if ([EMMethodKeyUpdateConversationsName isEqualToString:call.method]) { [self updateConversationsName:call.arguments - channelName:EMMethodKeyUpdateConversationsName + channelName:call.method result:result]; } else if ([EMMethodKeyAsyncFetchGroupAcks isEqualToString:call.method]) { [self fetchGroupReadAck:call.arguments - channelName:EMMethodKeyAsyncFetchGroupAcks + channelName:call.method result:result]; } else { diff --git a/ios/Classes/EMChatroomManagerWrapper.m b/ios/Classes/EMChatroomManagerWrapper.m index 6ba92b75..2833020e 100644 --- a/ios/Classes/EMChatroomManagerWrapper.m +++ b/ios/Classes/EMChatroomManagerWrapper.m @@ -35,91 +35,149 @@ - (instancetype)initWithChannelName:(NSString *)aChannelName - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { if ([EMMethodKeyJoinChatRoom isEqualToString:call.method]) { - [self joinChatroom:call.arguments result:result]; + [self joinChatroom:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyLeaveChatRoom isEqualToString:call.method]) { - [self leaveChatroom:call.arguments result:result]; + [self leaveChatroom:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyGetChatroomsFromServer isEqualToString:call.method]) { - [self getChatroomsFromServer:call.arguments result:result]; + [self getChatroomsFromServer:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyCreateChatRoom isEqualToString:call.method]) { - [self createChatroom:call.arguments result:result]; + [self createChatroom:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyDestroyChatRoom isEqualToString:call.method]) { - [self destroyChatRoom:call.arguments result:result]; + [self destroyChatRoom:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyFetchChatRoomFromServer isEqualToString:call.method]) { - [self fetchChatroomInfoFromServer:call.arguments result:result]; + [self fetchChatroomInfoFromServer:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyGetChatRoom isEqualToString:call.method]) { - [self getChatroom:call.arguments result:result]; + [self getChatroom:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyGetAllChatRooms isEqualToString:call.method]) { - [self getAllChatrooms:call.arguments result:result]; + [self getAllChatrooms:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyGetChatroomMemberListFromServer isEqualToString:call.method]) { - [self getChatroomMemberListFromServer:call.arguments result:result]; + [self getChatroomMemberListFromServer:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyFetchChatroomBlockListFromServer isEqualToString:call.method]) { - [self fetchChatroomBlockListFromServer:call.arguments result:result]; + [self fetchChatroomBlockListFromServer:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyGetChatroomMuteListFromServer isEqualToString:call.method]) { - [self getChatroomMuteListFromServer:call.arguments result:result]; + [self getChatroomMuteListFromServer:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyFetchChatroomAnnouncement isEqualToString:call.method]) { - [self fetchChatroomAnnouncement:call.arguments result:result]; + [self fetchChatroomAnnouncement:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyChatRoomUpdateSubject isEqualToString:call.method]) { - [self chatRoomUpdateSubject:call.arguments result:result]; + [self chatRoomUpdateSubject:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyChatRoomUpdateDescription isEqualToString:call.method]) { - [self chatRoomUpdateDescription:call.arguments result:result]; + [self chatRoomUpdateDescription:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyChatRoomRemoveMembers isEqualToString:call.method]) { - [self chatRoomRemoveMembers:call.arguments result:result]; + [self chatRoomRemoveMembers:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyChatRoomBlockMembers isEqualToString:call.method]) { - [self chatRoomBlockMembers:call.arguments result:result]; + [self chatRoomBlockMembers:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyChatRoomUnblockMembers isEqualToString:call.method]) { - [self chatRoomUnblockMembers:call.arguments result:result]; + [self chatRoomUnblockMembers:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyChangeChatRoomOwner isEqualToString:call.method]) { - [self chatRoomChangeOwner:call.arguments result:result]; + [self chatRoomChangeOwner:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyChatRoomAddAdmin isEqualToString:call.method]) { - [self chatRoomAddAdmin:call.arguments result:result]; + [self chatRoomAddAdmin:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyChatRoomRemoveAdmin isEqualToString:call.method]) { - [self chatRoomRemoveAdmin:call.arguments result:result]; + [self chatRoomRemoveAdmin:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyChatRoomMuteMembers isEqualToString:call.method]) { - [self chatRoomMuteMembers:call.arguments result:result]; + [self chatRoomMuteMembers:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyChatRoomUnmuteMembers isEqualToString:call.method]) { - [self chatRoomUnmuteMembers:call.arguments result:result]; + [self chatRoomUnmuteMembers:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyUpdateChatRoomAnnouncement isEqualToString:call.method]) { - [self updateChatroomAnnouncement:call.arguments result:result]; + [self updateChatroomAnnouncement:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyAddMembersToChatRoomWhiteList isEqualToString:call.method]) { - [self addMembersToChatRoomWhiteList:call.arguments result:result]; + [self addMembersToChatRoomWhiteList:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyRemoveMembersFromChatRoomWhiteList isEqualToString:call.method]) { - [self removeMembersFromChatRoomWhiteList:call.arguments result:result]; + [self removeMembersFromChatRoomWhiteList:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyFetchChatRoomWhiteListFromServer isEqualToString:call.method]) { - [self fetchChatRoomWhiteListFromServer:call.arguments result:result]; + [self fetchChatRoomWhiteListFromServer:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyIsMemberInChatRoomWhiteListFromServer isEqualToString:call.method]) { - [self isMemberInChatRoomWhiteListFromServer:call.arguments result:result]; + [self isMemberInChatRoomWhiteListFromServer:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyMuteAllChatRoomMembers isEqualToString:call.method]) { - [self muteAllChatRoomMembers:call.arguments result:result]; + [self muteAllChatRoomMembers:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyUnMuteAllChatRoomMembers isEqualToString:call.method]) { - [self unMuteAllChatRoomMembers:call.arguments result:result]; + [self unMuteAllChatRoomMembers:call.arguments + channelName:call.method + result:result]; } else { [super handleMethodCall:call result:result]; @@ -128,7 +186,9 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { #pragma mark - Actions -- (void)getChatroomsFromServer:(NSDictionary *)param result:(FlutterResult)result { +- (void)getChatroomsFromServer:(NSDictionary *)param + channelName:(NSString *)aChannelName + result:(FlutterResult)result { NSInteger page = [param[@"pageNum"] integerValue]; NSInteger pageSize = [param[@"pageSize"] integerValue]; @@ -139,13 +199,15 @@ - (void)getChatroomsFromServer:(NSDictionary *)param result:(FlutterResult)resul completion:^(EMPageResult *aResult, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetChatroomsFromServer + channelName:aChannelName error:aError object:[aResult toJson]]; }]; } -- (void)createChatroom:(NSDictionary *)param result:(FlutterResult)result { +- (void)createChatroom:(NSDictionary *)param + channelName:(NSString *)aChannelName + result:(FlutterResult)result { __weak typeof(self) weakSelf = self; @@ -162,13 +224,15 @@ - (void)createChatroom:(NSDictionary *)param result:(FlutterResult)result { completion:^(EMChatroom *aChatroom, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyCreateChatRoom + channelName:aChannelName error:aError object:[aChatroom toJson]]; }]; } -- (void)joinChatroom:(NSDictionary *)param result:(FlutterResult)result { +- (void)joinChatroom:(NSDictionary *)param + channelName:(NSString *)aChannelName + result:(FlutterResult)result { __weak typeof(self) weakSelf = self; NSString *chatroomId = param[@"roomId"]; @@ -176,13 +240,13 @@ - (void)joinChatroom:(NSDictionary *)param result:(FlutterResult)result { completion:^(EMChatroom *aChatroom, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyJoinChatRoom + channelName:aChannelName error:aError object:@(!!aChatroom)]; }]; } -- (void)leaveChatroom:(NSDictionary *)param result:(FlutterResult)result { +- (void)leaveChatroom:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; @@ -191,50 +255,50 @@ - (void)leaveChatroom:(NSDictionary *)param result:(FlutterResult)result { completion:^(EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyLeaveChatRoom + channelName:aChannelName error:aError object:nil]; }]; } -- (void)destroyChatRoom:(NSDictionary *)param result:(FlutterResult)result { +- (void)destroyChatRoom:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; NSString *chatroomId = param[@"roomId"]; [EMClient.sharedClient.roomManager destroyChatroom:chatroomId completion:^(EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyDestroyChatRoom + channelName:aChannelName error:aError object:nil]; }]; } -- (void)fetchChatroomInfoFromServer:(NSDictionary *)param result:(FlutterResult)result { +- (void)fetchChatroomInfoFromServer:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self)weakSelf = self; NSString *chatroomId = param[@"roomId"]; [EMClient.sharedClient.roomManager getChatroomSpecificationFromServerWithId:chatroomId completion:^(EMChatroom *aChatroom, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyFetchChatRoomFromServer + channelName:aChannelName error:aError object:[aChatroom toJson]]; }]; } -- (void)getChatroom:(NSDictionary *)param result:(FlutterResult)result { +- (void)getChatroom:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self)weakSelf = self; EMChatroom *chatroom = [EMChatroom chatroomWithId:param[@"roomId"]]; [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetChatRoom + channelName:aChannelName error:nil object:[chatroom toJson]]; } -- (void)getAllChatrooms:(NSDictionary *)param result:(FlutterResult)result { +- (void)getAllChatrooms:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.roomManager getChatroomsFromServerWithPage:0 @@ -247,13 +311,13 @@ - (void)getAllChatrooms:(NSDictionary *)param result:(FlutterResult)result { } [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetAllChatRooms + channelName:aChannelName error:aError object:list]; }]; } -- (void)getChatroomMemberListFromServer:(NSDictionary *)param result:(FlutterResult)result { +- (void)getChatroomMemberListFromServer:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; @@ -266,14 +330,14 @@ - (void)getChatroomMemberListFromServer:(NSDictionary *)param result:(FlutterRes completion:^(EMCursorResult *aResult, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetChatroomMemberListFromServer + channelName:aChannelName error:aError object:[aResult toJson]]; }]; } -- (void)fetchChatroomBlockListFromServer:(NSDictionary *)param result:(FlutterResult)result { +- (void)fetchChatroomBlockListFromServer:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; @@ -286,13 +350,13 @@ - (void)fetchChatroomBlockListFromServer:(NSDictionary *)param result:(FlutterRe completion:^(NSArray *aList, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyFetchChatroomBlockListFromServer + channelName:aChannelName error:aError object:aList]; }]; } -- (void)getChatroomMuteListFromServer:(NSDictionary *)param result:(FlutterResult)result { +- (void)getChatroomMuteListFromServer:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; @@ -305,13 +369,13 @@ - (void)getChatroomMuteListFromServer:(NSDictionary *)param result:(FlutterResul completion:^(NSArray *aList, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetChatroomMuteListFromServer + channelName:aChannelName error:aError object:aList]; }]; } -- (void)fetchChatroomAnnouncement:(NSDictionary *)param result:(FlutterResult)result { +- (void)fetchChatroomAnnouncement:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; @@ -320,13 +384,13 @@ - (void)fetchChatroomAnnouncement:(NSDictionary *)param result:(FlutterResult)re completion:^(NSString *aAnnouncement, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyFetchChatroomAnnouncement + channelName:aChannelName error:aError object:aAnnouncement]; }]; } -- (void)chatRoomUpdateSubject:(NSDictionary *)param result:(FlutterResult)result { +- (void)chatRoomUpdateSubject:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; NSString *subject = param[@"subject"]; NSString *chatroomId = param[@"roomId"]; @@ -336,13 +400,13 @@ - (void)chatRoomUpdateSubject:(NSDictionary *)param result:(FlutterResult)result { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyChatRoomUpdateSubject + channelName:aChannelName error:aError object:nil]; }]; } -- (void)chatRoomUpdateDescription:(NSDictionary *)param result:(FlutterResult)result { +- (void)chatRoomUpdateDescription:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; NSString *description = param[@"description"]; NSString *chatroomId = param[@"roomId"]; @@ -351,13 +415,13 @@ - (void)chatRoomUpdateDescription:(NSDictionary *)param result:(FlutterResult)re completion:^(EMChatroom *aChatroom, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyChatRoomUpdateDescription + channelName:aChannelName error:aError object:nil]; }]; } -- (void)chatRoomRemoveMembers:(NSDictionary *)param result:(FlutterResult)result { +- (void)chatRoomRemoveMembers:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; @@ -368,13 +432,13 @@ - (void)chatRoomRemoveMembers:(NSDictionary *)param result:(FlutterResult)result completion:^(EMChatroom *aChatroom, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyChatRoomRemoveMembers + channelName:aChannelName error:aError object:nil]; }]; } -- (void)chatRoomBlockMembers:(NSDictionary *)param result:(FlutterResult)result { +- (void)chatRoomBlockMembers:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; @@ -385,13 +449,13 @@ - (void)chatRoomBlockMembers:(NSDictionary *)param result:(FlutterResult)result completion:^(EMChatroom *aChatroom, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyChatRoomBlockMembers + channelName:aChannelName error:aError object:nil]; }]; } -- (void)chatRoomUnblockMembers:(NSDictionary *)param result:(FlutterResult)result { +- (void)chatRoomUnblockMembers:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; @@ -402,13 +466,13 @@ - (void)chatRoomUnblockMembers:(NSDictionary *)param result:(FlutterResult)resul completion:^(EMChatroom *aChatroom, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyChatRoomUnblockMembers + channelName:aChannelName error:aError object:nil]; }]; } -- (void)chatRoomChangeOwner:(NSDictionary *)param result:(FlutterResult)result { +- (void)chatRoomChangeOwner:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; @@ -419,13 +483,13 @@ - (void)chatRoomChangeOwner:(NSDictionary *)param result:(FlutterResult)result { completion:^(EMChatroom *aChatroom, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyChangeChatRoomOwner + channelName:aChannelName error:aError object:nil]; }]; } -- (void)chatRoomAddAdmin:(NSDictionary *)param result:(FlutterResult)result { +- (void)chatRoomAddAdmin:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; @@ -436,13 +500,13 @@ - (void)chatRoomAddAdmin:(NSDictionary *)param result:(FlutterResult)result { completion:^(EMChatroom *aChatroomp, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyChatRoomAddAdmin + channelName:aChannelName error:aError object:nil]; }]; } -- (void)chatRoomRemoveAdmin:(NSDictionary *)param result:(FlutterResult)result { +- (void)chatRoomRemoveAdmin:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; @@ -453,13 +517,13 @@ - (void)chatRoomRemoveAdmin:(NSDictionary *)param result:(FlutterResult)result { completion:^(EMChatroom *aChatroom, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyChatRoomRemoveAdmin + channelName:aChannelName error:aError object:nil]; }]; } -- (void)chatRoomMuteMembers:(NSDictionary *)param result:(FlutterResult)result { +- (void)chatRoomMuteMembers:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; @@ -472,13 +536,13 @@ - (void)chatRoomMuteMembers:(NSDictionary *)param result:(FlutterResult)result { completion:^(EMChatroom *aChatroom, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyChatRoomMuteMembers + channelName:aChannelName error:aError object:nil]; }]; } -- (void)chatRoomUnmuteMembers:(NSDictionary *)param result:(FlutterResult)result { +- (void)chatRoomUnmuteMembers:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; @@ -489,13 +553,13 @@ - (void)chatRoomUnmuteMembers:(NSDictionary *)param result:(FlutterResult)result completion:^(EMChatroom *aChatroom, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyChatRoomUnmuteMembers + channelName:aChannelName error:aError object:nil]; }]; } -- (void)updateChatroomAnnouncement:(NSDictionary *)param result:(FlutterResult)result { +- (void)updateChatroomAnnouncement:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; @@ -506,34 +570,34 @@ - (void)updateChatroomAnnouncement:(NSDictionary *)param result:(FlutterResult)r completion:^(EMChatroom *aChatroom, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyUpdateChatRoomAnnouncement + channelName:aChannelName error:aError object:@(!aError)]; }]; } // TODO: chatroom white list. -- (void)addMembersToChatRoomWhiteList:(NSDictionary *)param result:(FlutterResult)result { +- (void)addMembersToChatRoomWhiteList:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { } -- (void)removeMembersFromChatRoomWhiteList:(NSDictionary *)param result:(FlutterResult)result { +- (void)removeMembersFromChatRoomWhiteList:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { } -- (void)isMemberInChatRoomWhiteListFromServer:(NSDictionary *)param result:(FlutterResult)result { +- (void)isMemberInChatRoomWhiteListFromServer:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { } -- (void)fetchChatRoomWhiteListFromServer:(NSDictionary *)param result:(FlutterResult)result { +- (void)fetchChatRoomWhiteListFromServer:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { } -- (void)muteAllChatRoomMembers:(NSDictionary *)param result:(FlutterResult)result { +- (void)muteAllChatRoomMembers:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { } -- (void)unMuteAllChatRoomMembers:(NSDictionary *)param result:(FlutterResult)result { +- (void)unMuteAllChatRoomMembers:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { } diff --git a/ios/Classes/EMClientWrapper.m b/ios/Classes/EMClientWrapper.m index 4020b641..cfdc73e8 100644 --- a/ios/Classes/EMClientWrapper.m +++ b/ios/Classes/EMClientWrapper.m @@ -61,82 +61,110 @@ - (instancetype)initWithChannelName:(NSString *)aChannelName - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { if ([EMMethodKeyInit isEqualToString:call.method]) { - [self initSDKWithDict:call.arguments result:result]; + [self initSDKWithDict:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyCreateAccount isEqualToString:call.method]) { - [self createAccount:call.arguments result:result]; + [self createAccount:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyLogin isEqualToString:call.method]) { - [self login:call.arguments result:result]; + [self login:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyLogout isEqualToString:call.method]) { - [self logout:call.arguments result:result]; + [self logout:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyChangeAppKey isEqualToString:call.method]) { - [self changeAppKey:call.arguments result:result]; + [self changeAppKey:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyUploadLog isEqualToString:call.method]) { - [self uploadLog:call.arguments result:result]; + [self uploadLog:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyCompressLogs isEqualToString:call.method]) { - [self compressLogs:call.arguments result:result]; + [self compressLogs:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyGetLoggedInDevicesFromServer isEqualToString:call.method]) { - [self getLoggedInDevicesFromServer:call.arguments result:result]; + [self getLoggedInDevicesFromServer:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyKickDevice isEqualToString:call.method]) { - [self kickDevice:call.arguments result:result]; + [self kickDevice:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyKickAllDevices isEqualToString:call.method]) { - [self kickAllDevices:call.arguments result:result]; + [self kickAllDevices:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyIsLoggedInBefore isEqualToString:call.method]) { - [self isLoggedInBefore:call.arguments result:result]; + [self isLoggedInBefore:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyGetCurrentUser isEqualToString:call.method]) { - [self getCurrentUser:call.arguments result:result]; + [self getCurrentUser:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyGetToken isEqualToString:call.method]) { - [self getToken:call.arguments result:result]; + [self getToken:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyIsConnected isEqualToString:call.method]) { - [self isConnected:call.arguments result:result]; + [self isConnected:call.arguments + channelName:call.method + result:result]; } else { [super handleMethodCall:call result:result]; } } -- (void)getToken:(NSDictionary *)param result:(FlutterResult)result{ +- (void)getToken:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result{ [self wrapperCallBack:result - channelName:EMMethodKeyGetToken + channelName:aChannelName error:nil object:EMClient.sharedClient.accessUserToken]; } -- (void)isConnected:(NSDictionary *)param result:(FlutterResult)result{ +- (void)isConnected:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result{ [self wrapperCallBack:result - channelName:EMMethodKeyIsConnected + channelName:aChannelName error:nil object:@(EMClient.sharedClient.isConnected)]; } #pragma mark - Actions -- (void)initSDKWithDict:(NSDictionary *)param result:(FlutterResult)result { +- (void)initSDKWithDict:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; @@ -173,7 +201,7 @@ - (void)registerManagers { #pragma clang diagnostic pop } -- (void)createAccount:(NSDictionary *)param result:(FlutterResult)result { +- (void)createAccount:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self)weakSelf = self; NSString *username = param[@"username"]; NSString *password = param[@"password"]; @@ -182,13 +210,13 @@ - (void)createAccount:(NSDictionary *)param result:(FlutterResult)result { completion:^(NSString *aUsername, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyCreateAccount + channelName:aChannelName error:aError object:aUsername]; }]; } -- (void)login:(NSDictionary *)param result:(FlutterResult)result { +- (void)login:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self)weakSelf = self; NSString *username = param[@"username"]; NSString *pwdOrToken = param[@"pwdOrToken"]; @@ -201,7 +229,7 @@ - (void)login:(NSDictionary *)param result:(FlutterResult)result { { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyLogin + channelName:aChannelName error:aError object:EMClient.sharedClient.currentUsername]; }]; @@ -211,7 +239,7 @@ - (void)login:(NSDictionary *)param result:(FlutterResult)result { completion:^(NSString *aUsername, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyLogin + channelName:aChannelName error:aError object:@{ @"username": aUsername, @@ -221,59 +249,59 @@ - (void)login:(NSDictionary *)param result:(FlutterResult)result { } } -- (void)logout:(NSDictionary *)param result:(FlutterResult)result { +- (void)logout:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self)weakSelf = self; BOOL unbindToken = [param[@"unbindToken"] boolValue]; [EMClient.sharedClient logout:unbindToken completion:^(EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyLogout + channelName:aChannelName error:aError object:@(!aError)]; }]; } -- (void)changeAppKey:(NSDictionary *)param result:(FlutterResult)result { +- (void)changeAppKey:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self)weakSelf = self; NSString *appKey = param[@"appKey"]; EMError *aError = [EMClient.sharedClient changeAppkey:appKey]; [weakSelf wrapperCallBack:result - channelName:EMMethodKeyChangeAppKey + channelName:aChannelName error:aError object:@(!aError)]; } -- (void)getCurrentUser:(NSDictionary *)param result:(FlutterResult)result { +- (void)getCurrentUser:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; NSString* username = EMClient.sharedClient.currentUsername; [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetCurrentUser + channelName:aChannelName error:nil object:username]; } -- (void)uploadLog:(NSDictionary *)param result:(FlutterResult)result { +- (void)uploadLog:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self)weakSelf = self; [EMClient.sharedClient uploadDebugLogToServerWithCompletion:^(EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyUploadLog + channelName:aChannelName error:aError object:nil]; }]; } -- (void)compressLogs:(NSDictionary *)param result:(FlutterResult)result { +- (void)compressLogs:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self)weakSelf = self; [EMClient.sharedClient getLogFilesPathWithCompletion:^(NSString *aPath, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyCompressLogs + channelName:aChannelName error:aError object:aPath]; }]; } -- (void)kickDevice:(NSDictionary *)param result:(FlutterResult)result { +- (void)kickDevice:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self)weakSelf = self; NSString *username = param[@"username"]; NSString *password = param[@"password"]; @@ -285,13 +313,13 @@ - (void)kickDevice:(NSDictionary *)param result:(FlutterResult)result { completion:^(EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyKickDevice + channelName:aChannelName error:aError object:nil]; }]; } -- (void)kickAllDevices:(NSDictionary *)param result:(FlutterResult)result { +- (void)kickAllDevices:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self)weakSelf = self; NSString *username = param[@"username"]; NSString *password = param[@"password"]; @@ -300,27 +328,27 @@ - (void)kickAllDevices:(NSDictionary *)param result:(FlutterResult)result { completion:^(EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyKickAllDevices + channelName:aChannelName error:aError object:nil]; }]; } -- (void)isLoggedInBefore:(NSDictionary *)param result:(FlutterResult)result { +- (void)isLoggedInBefore:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [weakSelf wrapperCallBack:result - channelName:EMMethodKeyIsLoggedInBefore + channelName:aChannelName error:nil object:@(EMClient.sharedClient.isLoggedIn)]; } -- (void)onMultiDeviceEvent:(NSDictionary *)param result:(FlutterResult)result { +- (void)onMultiDeviceEvent:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { } -- (void)getLoggedInDevicesFromServer:(NSDictionary *)param result:(FlutterResult)result { +- (void)getLoggedInDevicesFromServer:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self)weakSelf = self; NSString *username = param[@"username"]; NSString *password = param[@"password"]; @@ -336,7 +364,7 @@ - (void)getLoggedInDevicesFromServer:(NSDictionary *)param result:(FlutterResult [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetLoggedInDevicesFromServer + channelName:aChannelName error:aError object:nil]; }]; diff --git a/ios/Classes/EMContactManagerWrapper.m b/ios/Classes/EMContactManagerWrapper.m index 71e11894..19d2e558 100644 --- a/ios/Classes/EMContactManagerWrapper.m +++ b/ios/Classes/EMContactManagerWrapper.m @@ -28,27 +28,49 @@ - (instancetype)initWithChannelName:(NSString *)aChannelName - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { if ([EMMethodKeyAddContact isEqualToString:call.method]) { - [self addContact:call.arguments result:result]; + [self addContact:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyDeleteContact isEqualToString:call.method]) { - [self deleteContact:call.arguments result:result]; + [self deleteContact:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyGetAllContactsFromServer isEqualToString:call.method]) { - [self getAllContactsFromServer:call.arguments result:result]; + [self getAllContactsFromServer:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyGetAllContactsFromDB isEqualToString:call.method]) { - [self getAllContactsFromDB:call.arguments result:result]; + [self getAllContactsFromDB:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyAddUserToBlockList isEqualToString:call.method]) { - [self addUserToBlockList:call.arguments result:result]; + [self addUserToBlockList:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyRemoveUserFromBlockList isEqualToString:call.method]) { - [self removeUserFromBlockList:call.arguments result:result]; + [self removeUserFromBlockList:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyGetBlockListFromServer isEqualToString:call.method]) { - [self getBlockListFromServer:call.arguments result:result]; + [self getBlockListFromServer:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyGetBlockListFromDB isEqualToString:call.method]){ - [self getBlockListFromDB:call.arguments result:result]; + [self getBlockListFromDB:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyAcceptInvitation isEqualToString:call.method]) { - [self acceptInvitation:call.arguments result:result]; + [self acceptInvitation:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyDeclineInvitation isEqualToString:call.method]) { - [self declineInvitation:call.arguments result:result]; + [self declineInvitation:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyGetSelfIdsOnOtherPlatform isEqualToString:call.method]) { - [self getSelfIdsOnOtherPlatform:call.arguments result:result]; + [self getSelfIdsOnOtherPlatform:call.arguments + channelName:call.method + result:result]; } else { [super handleMethodCall:call result:result]; } @@ -56,7 +78,7 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { #pragma mark - Actions -- (void)addContact:(NSDictionary *)param result:(FlutterResult)result { +- (void)addContact:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self)weakSelf = self; NSString *username = param[@"username"]; NSString *reason = param[@"reason"]; @@ -65,13 +87,13 @@ - (void)addContact:(NSDictionary *)param result:(FlutterResult)result { completion:^(NSString *aUsername, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyAddContact + channelName:aChannelName error:aError object:aUsername]; }]; } -- (void)deleteContact:(NSDictionary *)param result:(FlutterResult)result { +- (void)deleteContact:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self)weakSelf = self; NSString *username = param[@"username"]; BOOL keepConversation = [param[@"keepConversation"] boolValue]; @@ -80,109 +102,109 @@ - (void)deleteContact:(NSDictionary *)param result:(FlutterResult)result { completion:^(NSString *aUsername, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyDeleteContact + channelName:aChannelName error:aError object:aUsername]; }]; } -- (void)getAllContactsFromServer:(NSDictionary *)param result:(FlutterResult)result { +- (void)getAllContactsFromServer:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self)weakSelf = self; [EMClient.sharedClient.contactManager getContactsFromServerWithCompletion:^(NSArray *aList, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetAllContactsFromServer + channelName:aChannelName error:aError object:aList]; }]; } -- (void)getAllContactsFromDB:(NSDictionary *)param result:(FlutterResult)result { +- (void)getAllContactsFromDB:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self)weakSelf = self; NSArray *aList = EMClient.sharedClient.contactManager.getContacts; [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetAllContactsFromDB + channelName:aChannelName error:nil object:aList]; } -- (void)addUserToBlockList:(NSDictionary *)param result:(FlutterResult)result { +- (void)addUserToBlockList:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self)weakSelf = self; NSString *username = param[@"username"]; [EMClient.sharedClient.contactManager addUserToBlackList:username completion:^(NSString *aUsername, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyAddUserToBlockList + channelName:aChannelName error:aError object:aUsername]; }]; } -- (void)removeUserFromBlockList:(NSDictionary *)param result:(FlutterResult)result { +- (void)removeUserFromBlockList:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self)weakSelf = self; NSString *username = param[@"username"]; [EMClient.sharedClient.contactManager removeUserFromBlackList:username completion:^(NSString *aUsername, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyRemoveUserFromBlockList + channelName:aChannelName error:aError object:aUsername]; }]; } -- (void)getBlockListFromServer:(NSDictionary *)param result:(FlutterResult)result { +- (void)getBlockListFromServer:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self)weakSelf = self; [EMClient.sharedClient.contactManager getBlackListFromServerWithCompletion:^(NSArray *aList, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetBlockListFromServer + channelName:aChannelName error:aError object:aList]; }]; } -- (void)getBlockListFromDB:(NSDictionary *)param result:(FlutterResult)result { +- (void)getBlockListFromDB:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { NSArray * list = [EMClient.sharedClient.contactManager getBlackList]; - [self wrapperCallBack:result channelName:EMMethodKeyGetBlockListFromDB error:nil object:list]; + [self wrapperCallBack:result channelName:aChannelName error:nil object:list]; } -- (void)acceptInvitation:(NSDictionary *)param result:(FlutterResult)result { +- (void)acceptInvitation:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self)weakSelf = self; NSString *username = param[@"username"]; [EMClient.sharedClient.contactManager approveFriendRequestFromUser:username completion:^(NSString *aUsername, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyAcceptInvitation + channelName:aChannelName error:aError object:aUsername]; }]; } -- (void)declineInvitation:(NSDictionary *)param result:(FlutterResult)result { +- (void)declineInvitation:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self)weakSelf = self; NSString *username = param[@"username"]; [EMClient.sharedClient.contactManager declineFriendRequestFromUser:username completion:^(NSString *aUsername, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyDeclineInvitation + channelName:aChannelName error:aError object:aUsername]; }]; } -- (void)getSelfIdsOnOtherPlatform:(NSDictionary *)param result:(FlutterResult)result { +- (void)getSelfIdsOnOtherPlatform:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self)weakSelf = self; [EMClient.sharedClient.contactManager getSelfIdsOnOtherPlatformWithCompletion:^(NSArray *aList, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetSelfIdsOnOtherPlatform + channelName:aChannelName error:aError object:aList]; }]; diff --git a/ios/Classes/EMConversationWrapper.m b/ios/Classes/EMConversationWrapper.m index 67b3ff4b..3a1e7869 100644 --- a/ios/Classes/EMConversationWrapper.m +++ b/ios/Classes/EMConversationWrapper.m @@ -30,39 +30,73 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { if ([EMMethodKeyLoadMsgWithId isEqualToString:call.method]) { - [self loadMsgWithId:call.arguments result:result]; + [self loadMsgWithId:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyLoadMsgWithStartId isEqualToString:call.method]){ - [self loadMsgWithStartId:call.arguments result:result]; + [self loadMsgWithStartId:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyLoadMsgWithKeywords isEqualToString:call.method]){ - [self loadMsgWithKeywords:call.arguments result:result]; + [self loadMsgWithKeywords:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyLoadMsgWithMsgType isEqualToString:call.method]){ - [self loadMsgWithMsgType:call.arguments result:result]; + [self loadMsgWithMsgType:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyLoadMsgWithTime isEqualToString:call.method]){ - [self loadMsgWithTime:call.arguments result:result]; + [self loadMsgWithTime:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyGetUnreadMsgCount isEqualToString:call.method]) { - [self getUnreadMsgCount:call.arguments result:result]; + [self getUnreadMsgCount:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyMarkAllMsgsAsRead isEqualToString:call.method]) { - [self markAllMessagesAsRead:call.arguments result:result]; + [self markAllMessagesAsRead:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyMarkMsgAsRead isEqualToString:call.method]) { - [self markMessageAsRead:call.arguments result:result]; + [self markMessageAsRead:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeySyncConversationExt isEqualToString:call.method]){ - [self syncConversationExt:call.arguments result:result]; + [self syncConversationExt:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeySyncConversationName isEqualToString:call.method]){ - [self syncConversationName:call.arguments result:result]; + [self syncConversationName:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyRemoveMsg isEqualToString:call.method]) { - [self removeMessage:call.arguments result:result]; + [self removeMessage:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyGetLatestMsg isEqualToString:call.method]) { - [self getLatestMessage:call.arguments result:result]; + [self getLatestMessage:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyGetLatestMsgFromOthers isEqualToString:call.method]) { - [self getLatestMessageFromOthers:call.arguments result:result]; + [self getLatestMessageFromOthers:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyClearAllMsg isEqualToString:call.method]) { - [self clearAllMessages:call.arguments result:result]; + [self clearAllMessages:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyInsertMsg isEqualToString:call.method]) { - [self insertMessage:call.arguments result:result]; + [self insertMessage:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyAppendMsg isEqualToString:call.method]) { - [self appendMessage:call.arguments result:result]; + [self appendMessage:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyUpdateConversationMsg isEqualToString:call.method]) { - [self updateConversationMessage:call.arguments result:result]; + [self updateConversationMessage:call.arguments + channelName:call.method + result:result]; } else { [super handleMethodCall:call result:result]; } @@ -71,7 +105,7 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { #pragma mark - Private - (void)getConversationWithParam:(NSDictionary *)param - completion:(void(^)(EMConversation *conversation))aCompletion + completion:(void(^)(EMConversation *conversation))aCompletion { __weak NSString *conversationId = param[@"con_id"]; EMConversationType type = [EMConversation typeFromInt:[param[@"type"] intValue]]; @@ -84,19 +118,23 @@ - (void)getConversationWithParam:(NSDictionary *)param } #pragma mark - Actions -- (void)getUnreadMsgCount:(NSDictionary *)param result:(FlutterResult)result +- (void)getUnreadMsgCount:(NSDictionary *)param + channelName:(NSString *)aChannelName + result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [self getConversationWithParam:param completion:^(EMConversation *conversation) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetUnreadMsgCount + channelName:aChannelName error:nil object:@(conversation.unreadMessagesCount)]; }]; } -- (void)getLatestMessage:(NSDictionary *)param result:(FlutterResult)result +- (void)getLatestMessage:(NSDictionary *)param + channelName:(NSString *)aChannelName + result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [self getConversationWithParam:param @@ -104,13 +142,15 @@ - (void)getLatestMessage:(NSDictionary *)param result:(FlutterResult)result { EMMessage *msg = conversation.latestMessage; [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetLatestMsg + channelName:aChannelName error:nil object:[msg toJson]]; }]; } -- (void)getLatestMessageFromOthers:(NSDictionary *)param result:(FlutterResult)result +- (void)getLatestMessageFromOthers:(NSDictionary *)param + channelName:(NSString *)aChannelName + result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [self getConversationWithParam:param @@ -118,13 +158,15 @@ - (void)getLatestMessageFromOthers:(NSDictionary *)param result:(FlutterResult)r { EMMessage *msg = conversation.lastReceivedMessage; [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetLatestMsgFromOthers + channelName:aChannelName error:nil object:[msg toJson]]; }]; } -- (void)markMessageAsRead:(NSDictionary *)param result:(FlutterResult)result +- (void)markMessageAsRead:(NSDictionary *)param + channelName:(NSString *)aChannelName + result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [self getConversationWithParam:param @@ -135,13 +177,15 @@ - (void)markMessageAsRead:(NSDictionary *)param result:(FlutterResult)result [conversation markMessageAsReadWithId:msgId error:&error]; [weakSelf wrapperCallBack:result - channelName:EMMethodKeyMarkMsgAsRead + channelName:aChannelName error:nil object:@(YES)]; }]; } -- (void)syncConversationName:(NSDictionary *)param result:(FlutterResult)result +- (void)syncConversationName:(NSDictionary *)param + channelName:(NSString *)aChannelName + result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [self getConversationWithParam:param @@ -155,13 +199,15 @@ - (void)syncConversationName:(NSDictionary *)param result:(FlutterResult)result ext[@"con_name"] = name; conversation.ext = ext; [weakSelf wrapperCallBack:result - channelName:EMMethodKeySyncConversationName + channelName:aChannelName error:nil object:@(YES)]; }]; } -- (void)syncConversationExt:(NSDictionary *)param result:(FlutterResult)result +- (void)syncConversationExt:(NSDictionary *)param + channelName:(NSString *)aChannelName + result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [self getConversationWithParam:param @@ -170,13 +216,15 @@ - (void)syncConversationExt:(NSDictionary *)param result:(FlutterResult)result NSDictionary *ext = param[@"ext"]; conversation.ext = ext; [weakSelf wrapperCallBack:result - channelName:EMMethodKeySyncConversationExt + channelName:aChannelName error:nil object:@(YES)]; }]; } -- (void)markAllMessagesAsRead:(NSDictionary *)param result:(FlutterResult)result +- (void)markAllMessagesAsRead:(NSDictionary *)param + channelName:(NSString *)aChannelName + result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [self getConversationWithParam:param @@ -184,13 +232,15 @@ - (void)markAllMessagesAsRead:(NSDictionary *)param result:(FlutterResult)result EMError *error = nil; [conversation markAllMessagesAsRead:&error]; [weakSelf wrapperCallBack:result - channelName:EMMethodKeyMarkAllMsgsAsRead + channelName:aChannelName error:error object:@(!error)]; }]; } -- (void)insertMessage:(NSDictionary *)param result:(FlutterResult)result +- (void)insertMessage:(NSDictionary *)param + channelName:(NSString *)aChannelName + result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [self getConversationWithParam:param @@ -202,13 +252,14 @@ - (void)insertMessage:(NSDictionary *)param result:(FlutterResult)result EMError *error = nil; [conversation insertMessage:msg error:&error]; [weakSelf wrapperCallBack:result - channelName:EMMethodKeyInsertMsg + channelName:aChannelName error:error object:@(!error)]; }]; } - (void)appendMessage:(NSDictionary *)param + channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; @@ -221,13 +272,14 @@ - (void)appendMessage:(NSDictionary *)param EMError *error = nil; [conversation appendMessage:msg error:&error]; [weakSelf wrapperCallBack:result - channelName:EMMethodKeyAppendMsg + channelName:aChannelName error:error object:@(!error)]; }]; } - (void)updateConversationMessage:(NSDictionary *)param + channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; @@ -240,13 +292,13 @@ - (void)updateConversationMessage:(NSDictionary *)param EMError *error = nil; [conversation updateMessageChange:msg error:&error]; [weakSelf wrapperCallBack:result - channelName:EMMethodKeyUpdateConversationMsg + channelName:aChannelName error:error object:@(!error)]; }]; } -- (void)removeMessage:(NSDictionary *)param result:(FlutterResult)result +- (void)removeMessage:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [self getConversationWithParam:param @@ -257,13 +309,13 @@ - (void)removeMessage:(NSDictionary *)param result:(FlutterResult)result [conversation deleteMessageWithId:msgId error:&error]; [weakSelf wrapperCallBack:result - channelName:EMMethodKeyRemoveMsg + channelName:aChannelName error:error object:@(!error)]; }]; } -- (void)clearAllMessages:(NSDictionary *)param result:(FlutterResult)result +- (void)clearAllMessages:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [self getConversationWithParam:param @@ -271,14 +323,14 @@ - (void)clearAllMessages:(NSDictionary *)param result:(FlutterResult)result EMError *error = nil; [conversation deleteAllMessages:&error]; [weakSelf wrapperCallBack:result - channelName:EMMethodKeyClearAllMsg + channelName:aChannelName error:error object:@(!error)]; }]; } #pragma mark - load messages -- (void)loadMsgWithId:(NSDictionary *)param result:(FlutterResult)result +- (void)loadMsgWithId:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; NSString *msgId = param[@"msg_id"]; @@ -289,14 +341,14 @@ - (void)loadMsgWithId:(NSDictionary *)param result:(FlutterResult)result EMMessage *msg = [conversation loadMessageWithId:msgId error:&error]; [weakSelf wrapperCallBack:result - channelName:EMMethodKeyLoadMsgWithId + channelName:aChannelName error:error object:[msg toJson]]; }]; } -- (void)loadMsgWithMsgType:(NSDictionary *)param result:(FlutterResult)result{ +- (void)loadMsgWithMsgType:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result{ __weak typeof(self) weakSelf = self; EMMessageBodyType type = [EMMessageBody typeFromString:param[@"type"]]; @@ -321,14 +373,14 @@ - (void)loadMsgWithMsgType:(NSDictionary *)param result:(FlutterResult)result{ [msgJsonAry addObject:[msg toJson]]; } [weakSelf wrapperCallBack:result - channelName:EMMethodKeyLoadMsgWithMsgType + channelName:aChannelName error:aError object:msgJsonAry]; }]; }]; } -- (void)loadMsgWithStartId:(NSDictionary *)param result:(FlutterResult)result +- (void)loadMsgWithStartId:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; NSString *startId = param[@"startId"]; @@ -348,14 +400,14 @@ - (void)loadMsgWithStartId:(NSDictionary *)param result:(FlutterResult)result } [weakSelf wrapperCallBack:result - channelName:EMMethodKeyLoadMsgWithStartId + channelName:aChannelName error:aError object:jsonMsgs]; }]; }]; } -- (void)loadMsgWithKeywords:(NSDictionary *)param result:(FlutterResult)result +- (void)loadMsgWithKeywords:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; NSString * keywords = param[@"keywords"]; @@ -379,14 +431,14 @@ - (void)loadMsgWithKeywords:(NSDictionary *)param result:(FlutterResult)result [msgJsonAry addObject:[msg toJson]]; } [weakSelf wrapperCallBack:result - channelName:EMMethodKeyLoadMsgWithKeywords + channelName:aChannelName error:aError object:msgJsonAry]; }]; }]; } -- (void)loadMsgWithTime:(NSDictionary *)param result:(FlutterResult)result{ +- (void)loadMsgWithTime:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result{ __weak typeof(self) weakSelf = self; long long startTime = [param[@"startTime"] longLongValue]; long long entTime = [param[@"endTime"] longLongValue]; @@ -405,7 +457,7 @@ - (void)loadMsgWithTime:(NSDictionary *)param result:(FlutterResult)result{ [msgJsonAry addObject:[msg toJson]]; } [weakSelf wrapperCallBack:result - channelName:EMMethodKeyLoadMsgWithTime + channelName:aChannelName error:aError object:msgJsonAry]; }]; diff --git a/ios/Classes/EMGroup+Flutter.m b/ios/Classes/EMGroup+Flutter.m index d7915fa9..b4b264c5 100644 --- a/ios/Classes/EMGroup+Flutter.m +++ b/ios/Classes/EMGroup+Flutter.m @@ -22,7 +22,6 @@ - (NSDictionary *)toJson { ret[@"adminList"] = self.adminList; ret[@"blockList"] = self.blacklist; ret[@"muteList"] = self.muteList; - ret[@"sharedFileList"] = self.sharedFileList; ret[@"noticeEnable"] = @(self.isPushNotificationEnabled); ret[@"messageBlocked"] = @(self.isBlocked); ret[@"isAllMemberMuted"] = @(self.isMuteAllMembers); diff --git a/ios/Classes/EMGroupManagerWrapper.m b/ios/Classes/EMGroupManagerWrapper.m index fce21a9f..b649f46b 100644 --- a/ios/Classes/EMGroupManagerWrapper.m +++ b/ios/Classes/EMGroupManagerWrapper.m @@ -34,186 +34,278 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { if([EMMethodKeyGetGroupWithId isEqualToString:call.method]) { - [self getGroupWithId:call.arguments result:result]; + [self getGroupWithId:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyGetJoinedGroups isEqualToString:call.method]) { - [self getJoinedGroups:call.arguments result:result]; + [self getJoinedGroups:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyGetGroupsWithoutPushNotification isEqualToString:call.method]) { - [self getGroupsWithoutPushNotification:call.arguments result:result]; + [self getGroupsWithoutPushNotification:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyGetJoinedGroupsFromServer isEqualToString:call.method]) { - [self getJoinedGroupsFromServer:call.arguments result:result]; + [self getJoinedGroupsFromServer:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyGetPublicGroupsFromServer isEqualToString:call.method]) { - [self getPublicGroupsFromServer:call.arguments result:result]; + [self getPublicGroupsFromServer:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyCreateGroup isEqualToString:call.method]) { - [self createGroup:call.arguments result:result]; + [self createGroup:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyGetGroupSpecificationFromServer isEqualToString:call.method]) { - [self getGroupSpecificationFromServer:call.arguments result:result]; + [self getGroupSpecificationFromServer:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyGetGroupMemberListFromServer isEqualToString:call.method]) { - [self getGroupMemberListFromServer:call.arguments result:result]; + [self getGroupMemberListFromServer:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyGetGroupBlockListFromServer isEqualToString:call.method]) { - [self getGroupBlockListFromServer:call.arguments result:result]; + [self getGroupBlockListFromServer:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyGetGroupMuteListFromServer isEqualToString:call.method]) { - [self getGroupMuteListFromServer:call.arguments result:result]; + [self getGroupMuteListFromServer:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyGetGroupWhiteListFromServer isEqualToString:call.method]) { - [self getGroupWhiteListFromServer:call.arguments result:result]; + [self getGroupWhiteListFromServer:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyIsMemberInWhiteListFromServer isEqualToString:call.method]) { - [self isMemberInWhiteListFromServer:call.arguments result:result]; + [self isMemberInWhiteListFromServer:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyGetGroupFileListFromServer isEqualToString:call.method]) { - [self getGroupFileListFromServer:call.arguments result:result]; + [self getGroupFileListFromServer:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyGetGroupAnnouncementFromServer isEqualToString:call.method]) { - [self getGroupAnnouncementFromServer:call.arguments result:result]; + [self getGroupAnnouncementFromServer:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyAddMembers isEqualToString:call.method]) { - [self addMembers:call.arguments result:result]; + [self addMembers:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyInviterUser isEqualToString:call.method]){ - [self inviterUsers:call.arguments result:result]; + [self inviterUsers:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyRemoveMembers isEqualToString:call.method]) { - [self removeMembers:call.arguments result:result]; + [self removeMembers:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyBlockMembers isEqualToString:call.method]) { - [self blockMembers:call.arguments result:result]; + [self blockMembers:call.arguments + channelName:call.method + result:result]; } else if ([EMMethodKeyUnblockMembers isEqualToString:call.method]) { - [self unblockMembers:call.arguments result:result]; + [self unblockMembers:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyUpdateGroupSubject isEqualToString:call.method]) { - [self updateGroupSubject:call.arguments result:result]; + [self updateGroupSubject:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyUpdateDescription isEqualToString:call.method]) { - [self updateDescription:call.arguments result:result]; + [self updateDescription:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyLeaveGroup isEqualToString:call.method]) { - [self leaveGroup:call.arguments result:result]; + [self leaveGroup:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyDestroyGroup isEqualToString:call.method]) { - [self destroyGroup:call.arguments result:result]; + [self destroyGroup:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyBlockGroup isEqualToString:call.method]) { - [self blockGroup:call.arguments result:result]; + [self blockGroup:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyUnblockGroup isEqualToString:call.method]) { - [self unblockGroup:call.arguments result:result]; + [self unblockGroup:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyUpdateGroupOwner isEqualToString:call.method]) { - [self updateGroupOwner:call.arguments result:result]; + [self updateGroupOwner:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyAddAdmin isEqualToString:call.method]) { - [self addAdmin:call.arguments result:result]; + [self addAdmin:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyRemoveAdmin isEqualToString:call.method]) { - [self removeAdmin:call.arguments result:result]; + [self removeAdmin:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyMuteMembers isEqualToString:call.method]) { - [self muteMembers:call.arguments result:result]; + [self muteMembers:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyUnMuteMembers isEqualToString:call.method]) { - [self unMuteMembers:call.arguments result:result]; + [self unMuteMembers:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyMuteAllMembers isEqualToString:call.method]) { - [self muteAllMembers:call.arguments result:result]; + [self muteAllMembers:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyUnMuteAllMembers isEqualToString:call.method]) { - [self unMuteAllMembers:call.arguments result:result]; + [self unMuteAllMembers:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyAddWhiteList isEqualToString:call.method]) { - [self addWhiteList:call.arguments result:result]; + [self addWhiteList:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyRemoveWhiteList isEqualToString:call.method]) { - [self removeWhiteList:call.arguments result:result]; + [self removeWhiteList:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyUploadGroupSharedFile isEqualToString:call.method]) { - [self uploadGroupSharedFile:call.arguments result:result]; + [self uploadGroupSharedFile:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyDownloadGroupSharedFile isEqualToString:call.method]) { - [self downloadGroupSharedFile:call.arguments result:result]; + [self downloadGroupSharedFile:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyRemoveGroupSharedFile isEqualToString:call.method]) { - [self removeGroupSharedFile:call.arguments result:result]; + [self removeGroupSharedFile:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyUpdateGroupAnnouncement isEqualToString:call.method]) { - [self updateGroupAnnouncement:call.arguments result:result]; + [self updateGroupAnnouncement:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyUpdateGroupExt isEqualToString:call.method]) { - [self updateGroupExt:call.arguments result:result]; + [self updateGroupExt:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyJoinPublicGroup isEqualToString:call.method]) { - [self joinPublicGroup:call.arguments result:result]; + [self joinPublicGroup:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyRequestToJoinPublicGroup isEqualToString:call.method]) { - [self requestToJoinPublicGroup:call.arguments result:result]; + [self requestToJoinPublicGroup:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyAcceptJoinApplication isEqualToString:call.method]) { - [self acceptJoinApplication:call.arguments result:result]; + [self acceptJoinApplication:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyDeclineJoinApplication isEqualToString:call.method]) { - [self declineJoinApplication:call.arguments result:result]; + [self declineJoinApplication:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyAcceptInvitationFromGroup isEqualToString:call.method]) { - [self acceptInvitationFromGroup:call.arguments result:result]; + [self acceptInvitationFromGroup:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyDeclineInvitationFromGroup isEqualToString:call.method]) { - [self declineInvitationFromGroup:call.arguments result:result]; + [self declineInvitationFromGroup:call.arguments + channelName:call.method + result:result]; } else if([EMMethodKeyIgnoreGroupPush isEqualToString:call.method]) { - [self ignoreGroupPush:call.arguments result:result]; + [self ignoreGroupPush:call.arguments + channelName:call.method + result:result]; } else { @@ -223,17 +315,17 @@ - (void)handleMethodCall:(FlutterMethodCall*)call #pragma mark - Actions -- (void)getGroupWithId:(NSDictionary *)param result:(FlutterResult)result { +- (void)getGroupWithId:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; EMGroup *group = [EMGroup groupWithId:param[@"groupId"]]; [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetGroupWithId + channelName:aChannelName error:nil object:[group toJson]]; } -- (void)getJoinedGroups:(NSDictionary *)param result:(FlutterResult)result { +- (void)getJoinedGroups:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; NSArray *joinedGroups = [EMClient.sharedClient.groupManager getJoinedGroups]; NSMutableArray *list = [NSMutableArray array]; @@ -241,12 +333,12 @@ - (void)getJoinedGroups:(NSDictionary *)param result:(FlutterResult)result { [list addObject:[group toJson]]; } [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetJoinedGroups + channelName:aChannelName error:nil object:list]; } -- (void)getGroupsWithoutPushNotification:(NSDictionary *)param result:(FlutterResult)result { +- (void)getGroupsWithoutPushNotification:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; EMError *error = nil; NSArray *groups = [EMClient.sharedClient.groupManager getGroupsWithoutPushNotification:&error]; @@ -255,12 +347,12 @@ - (void)getGroupsWithoutPushNotification:(NSDictionary *)param result:(FlutterRe [list addObject:[group toJson]]; } [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetJoinedGroups + channelName:aChannelName error:error object:list]; } -- (void)getJoinedGroupsFromServer:(NSDictionary *)param result:(FlutterResult)result { +- (void)getJoinedGroupsFromServer:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager getJoinedGroupsFromServerWithPage:[param[@"pageNum"] intValue] pageSize:[param[@"pageSize"] intValue] @@ -271,27 +363,27 @@ - (void)getJoinedGroupsFromServer:(NSDictionary *)param result:(FlutterResult)re [list addObject:[group toJson]]; } [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetJoinedGroupsFromServer + channelName:aChannelName error:aError object:list]; }]; } -- (void)getPublicGroupsFromServer:(NSDictionary *)param result:(FlutterResult)result { +- (void)getPublicGroupsFromServer:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager getPublicGroupsFromServerWithCursor:param[@"cursor"] pageSize:[param[@"pageSize"] integerValue] completion:^(EMCursorResult *aResult, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetPublicGroupsFromServer + channelName:aChannelName error:aError object:[aResult toJson]]; }]; } -- (void)createGroup:(NSDictionary *)param result:(FlutterResult)result { +- (void)createGroup:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager createGroupWithSubject:param[@"groupName"] description:param[@"desc"] @@ -301,25 +393,25 @@ - (void)createGroup:(NSDictionary *)param result:(FlutterResult)result { completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyCreateGroup + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)getGroupSpecificationFromServer:(NSDictionary *)param result:(FlutterResult)result { +- (void)getGroupSpecificationFromServer:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager getGroupSpecificationFromServerWithId:param[@"groupId"] completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetGroupSpecificationFromServer + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)getGroupMemberListFromServer:(NSDictionary *)param result:(FlutterResult)result { +- (void)getGroupMemberListFromServer:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager getGroupMemberListFromServerWithId:param[@"groupId"] cursor:param[@"cursor"] @@ -327,13 +419,13 @@ - (void)getGroupMemberListFromServer:(NSDictionary *)param result:(FlutterResult completion:^(EMCursorResult *aResult, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetGroupMemberListFromServer + channelName:aChannelName error:aError object:[aResult toJson]]; }]; } -- (void)getGroupBlockListFromServer:(NSDictionary *)param result:(FlutterResult)result { +- (void)getGroupBlockListFromServer:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager getGroupBlacklistFromServerWithId:param[@"groupId"] pageNumber:[param[@"pageNum"] intValue] @@ -341,13 +433,13 @@ - (void)getGroupBlockListFromServer:(NSDictionary *)param result:(FlutterResult) completion:^(NSArray *aList, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetGroupBlockListFromServer + channelName:aChannelName error:aError object:aList]; }]; } -- (void)getGroupMuteListFromServer:(NSDictionary *)param result:(FlutterResult)result { +- (void)getGroupMuteListFromServer:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager getGroupMuteListFromServerWithId:param[@"groupId"] pageNumber:[param[@"pageNum"] intValue] @@ -355,62 +447,68 @@ - (void)getGroupMuteListFromServer:(NSDictionary *)param result:(FlutterResult)r completion:^(NSArray *aList, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetGroupMuteListFromServer + channelName:aChannelName error:aError object:aList]; }]; } -- (void)getGroupWhiteListFromServer:(NSDictionary *)param result:(FlutterResult)result { +- (void)getGroupWhiteListFromServer:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager getGroupWhiteListFromServerWithId:param[@"groupId"] completion:^(NSArray *aList, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetGroupWhiteListFromServer + channelName:aChannelName error:aError object:aList]; }]; } -- (void)isMemberInWhiteListFromServer:(NSDictionary *)param result:(FlutterResult)result { +- (void)isMemberInWhiteListFromServer:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager isMemberInWhiteListFromServerWithGroupId:param[@"groupId"] completion:^(BOOL inWhiteList, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyIsMemberInWhiteListFromServer + channelName:aChannelName error:aError object:@(inWhiteList)]; }]; } -- (void)getGroupFileListFromServer:(NSDictionary *)param result:(FlutterResult)result { +- (void)getGroupFileListFromServer:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager getGroupFileListWithId:param[@"groupId"] pageNumber:[param[@"pageNum"] intValue] pageSize:[param[@"pageSize"] intValue] completion:^(NSArray *aList, EMError *aError) { + + NSMutableArray *array = [NSMutableArray array]; + for (EMGroupSharedFile *file in aList) { + [array addObject:[file toJson]]; + } + [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetGroupFileListFromServer + channelName:aChannelName error:aError - object:aList]; + object:array]; }]; } -- (void)getGroupAnnouncementFromServer:(NSDictionary *)param result:(FlutterResult)result { +- (void)getGroupAnnouncementFromServer:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager getGroupAnnouncementWithId:param[@"groupId"] completion:^(NSString *aAnnouncement, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyGetGroupAnnouncementFromServer + channelName:aChannelName error:aError object:aAnnouncement]; }]; } -- (void)addMembers:(NSDictionary *)param result:(FlutterResult)result { +- (void)addMembers:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager addMembers:param[@"members"] toGroup:param[@"groupId"] @@ -418,182 +516,182 @@ - (void)addMembers:(NSDictionary *)param result:(FlutterResult)result { completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyAddMembers + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)inviterUsers:(NSDictionary *)param result:(FlutterResult)result { +- (void)inviterUsers:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager addMembers:param[@"members"] toGroup:param[@"groupId"] message:param[@"reason"] completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyInviterUser + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)removeMembers:(NSDictionary *)param result:(FlutterResult)result { +- (void)removeMembers:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager removeMembers:param[@"members"] fromGroup:param[@"groupId"] completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyRemoveMembers + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)blockMembers:(NSDictionary *)param result:(FlutterResult)result { +- (void)blockMembers:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager blockMembers:param[@"members"] fromGroup:param[@"groupId"] completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyBlockMembers + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)unblockMembers:(NSDictionary *)param result:(FlutterResult)result { +- (void)unblockMembers:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager unblockMembers:param[@"members"] fromGroup:param[@"groupId"] completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyUnblockMembers + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)updateGroupSubject:(NSDictionary *)param result:(FlutterResult)result { +- (void)updateGroupSubject:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager updateGroupSubject:param[@"name"] forGroup:param[@"groupId"] completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyUpdateGroupSubject + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)updateDescription:(NSDictionary *)param result:(FlutterResult)result { +- (void)updateDescription:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager updateDescription:param[@"desc"] forGroup:param[@"groupId"] completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyUpdateDescription + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)leaveGroup:(NSDictionary *)param result:(FlutterResult)result { +- (void)leaveGroup:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager leaveGroup:param[@"groupId"] completion:^(EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyLeaveGroup + channelName:aChannelName error:aError object:nil]; }]; } -- (void)destroyGroup:(NSDictionary *)param result:(FlutterResult)result { +- (void)destroyGroup:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager destroyGroup:param[@"groupId"] finishCompletion:^(EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyDestroyGroup + channelName:aChannelName error:aError object:nil]; }]; } -- (void)blockGroup:(NSDictionary *)param result:(FlutterResult)result { +- (void)blockGroup:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager blockGroup:param[@"groupId"] completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyBlockGroup + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)unblockGroup:(NSDictionary *)param result:(FlutterResult)result { +- (void)unblockGroup:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager unblockGroup:param[@"groupId"] completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyUnblockGroup + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)updateGroupOwner:(NSDictionary *)param result:(FlutterResult)result { +- (void)updateGroupOwner:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager updateGroupOwner:param[@"groupId"] newOwner:param[@"owner"] completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyUpdateGroupOwner + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)addAdmin:(NSDictionary *)param result:(FlutterResult)result { +- (void)addAdmin:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager addAdmin:param[@"admin"] toGroup:param[@"groupId"] completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyAddAdmin + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)removeAdmin:(NSDictionary *)param result:(FlutterResult)result { +- (void)removeAdmin:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager removeAdmin:param[@"admin"] fromGroup:param[@"groupId"] completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyRemoveAdmin + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)muteMembers:(NSDictionary *)param result:(FlutterResult)result { +- (void)muteMembers:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager muteMembers:param[@"members"] muteMilliseconds:[param[@"duration"] integerValue] @@ -601,75 +699,75 @@ - (void)muteMembers:(NSDictionary *)param result:(FlutterResult)result { completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyMuteMembers + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)unMuteMembers:(NSDictionary *)param result:(FlutterResult)result { +- (void)unMuteMembers:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager unmuteMembers:param[@"members"] fromGroup:param[@"groupId"] completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyUnMuteMembers + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)muteAllMembers:(NSDictionary *)param result:(FlutterResult)result { +- (void)muteAllMembers:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager muteAllMembersFromGroup:param[@"groupId"] completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyMuteAllMembers + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)unMuteAllMembers:(NSDictionary *)param result:(FlutterResult)result { +- (void)unMuteAllMembers:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager unmuteAllMembersFromGroup:param[@"groupId"] completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyUnMuteAllMembers + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)addWhiteList:(NSDictionary *)param result:(FlutterResult)result { +- (void)addWhiteList:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager addWhiteListMembers:param[@"members"] fromGroup:param[@"groupId"] completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyAddWhiteList + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)removeWhiteList:(NSDictionary *)param result:(FlutterResult)result { - // __weak typeof(self) weakSelf = self; - // [EMClient.sharedClient.groupManager removeWhiteListMembers:param[@"members"] - // fromGroup:param[@"groupId"] - // completion:^(EMGroup *aGroup, EMError *aError) { - // [weakSelf wrapperCallBack:result - // channelName:EMMethodKeyAddWhiteList - // error:aError - // object:[aGroup toJson]]; - // }]; +- (void)removeWhiteList:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { + __weak typeof(self) weakSelf = self; + [EMClient.sharedClient.groupManager removeWhiteListMembers:param[@"members"] + fromGroup:param[@"groupId"] + completion:^(EMGroup *aGroup, EMError *aError) { + [weakSelf wrapperCallBack:result + channelName:aChannelName + error:aError + object:[aGroup toJson]]; + }]; } -// TODO: dujiepeng. -- (void)uploadGroupSharedFile:(NSDictionary *)param result:(FlutterResult)result { + +- (void)uploadGroupSharedFile:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager uploadGroupSharedFileWithId:param[@"groupId"] filePath:param[@"filePath"] @@ -679,13 +777,13 @@ - (void)uploadGroupSharedFile:(NSDictionary *)param result:(FlutterResult)result } completion:^(EMGroupSharedFile *aSharedFile, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyUploadGroupSharedFile + channelName:aChannelName error:aError object:@(!aError)]; }]; } -- (void)downloadGroupSharedFile:(NSDictionary *)param result:(FlutterResult)result { +- (void)downloadGroupSharedFile:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager downloadGroupSharedFileWithId:param[@"groupId"] filePath:param[@"savePath"] @@ -696,91 +794,91 @@ - (void)downloadGroupSharedFile:(NSDictionary *)param result:(FlutterResult)resu } completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyDownloadGroupSharedFile + channelName:aChannelName error:aError object:@(!aError)]; }]; } -- (void)removeGroupSharedFile:(NSDictionary *)param result:(FlutterResult)result { +- (void)removeGroupSharedFile:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager removeGroupSharedFileWithId:param[@"groupId"] sharedFileId:param[@"fileId"] completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyRemoveGroupSharedFile + channelName:aChannelName error:aError object:@(!aError)]; }]; } -- (void)updateGroupAnnouncement:(NSDictionary *)param result:(FlutterResult)result { +- (void)updateGroupAnnouncement:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager updateGroupAnnouncementWithId:param[@"groupId"] announcement:param[@"announcement"] completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyUpdateGroupAnnouncement + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)updateGroupExt:(NSDictionary *)param result:(FlutterResult)result { +- (void)updateGroupExt:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager updateGroupExtWithId:param[@"groupId"] ext:param[@"ext"] completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyUpdateGroupExt + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)joinPublicGroup:(NSDictionary *)param result:(FlutterResult)result { +- (void)joinPublicGroup:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager joinPublicGroup:param[@"groupId"] completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyJoinPublicGroup + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)requestToJoinPublicGroup:(NSDictionary *)param result:(FlutterResult)result { +- (void)requestToJoinPublicGroup:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager requestToJoinPublicGroup:param[@"groupId"] message:param[@"reason"] completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyRequestToJoinPublicGroup + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)acceptJoinApplication:(NSDictionary *)param result:(FlutterResult)result { +- (void)acceptJoinApplication:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager approveJoinGroupRequest:param[@"groupId"] sender:param[@"username"] completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyAcceptJoinApplication + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)declineJoinApplication:(NSDictionary *)param result:(FlutterResult)result { +- (void)declineJoinApplication:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager declineJoinGroupRequest:param[@"groupId"] sender:param[@"username"] @@ -788,26 +886,26 @@ - (void)declineJoinApplication:(NSDictionary *)param result:(FlutterResult)resul completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyDeclineJoinApplication + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)acceptInvitationFromGroup:(NSDictionary *)param result:(FlutterResult)result { +- (void)acceptInvitationFromGroup:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager acceptInvitationFromGroup:param[@"groupId"] inviter:param[@"inviter"] completion:^(EMGroup *aGroup, EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyAcceptInvitationFromGroup + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; } -- (void)declineInvitationFromGroup:(NSDictionary *)param result:(FlutterResult)result { +- (void)declineInvitationFromGroup:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; [EMClient.sharedClient.groupManager declineGroupInvitation:param[@"groupId"] inviter:param[@"inviter"] @@ -815,13 +913,13 @@ - (void)declineInvitationFromGroup:(NSDictionary *)param result:(FlutterResult)r completion:^(EMError *aError) { [weakSelf wrapperCallBack:result - channelName:EMMethodKeyDeclineInvitationFromGroup + channelName:aChannelName error:aError object:nil]; }]; } -- (void)ignoreGroupPush:(NSDictionary *)param result:(FlutterResult)result { +- (void)ignoreGroupPush:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self) weakSelf = self; __block NSString *groupId = param[@"groupId"]; @@ -830,7 +928,7 @@ - (void)ignoreGroupPush:(NSDictionary *)param result:(FlutterResult)result { completion:^(EMError * _Nonnull aError) { EMGroup *aGroup = [EMGroup groupWithId:groupId]; [weakSelf wrapperCallBack:result - channelName:EMMethodKeyIgnoreGroupPush + channelName:aChannelName error:aError object:[aGroup toJson]]; }]; diff --git a/ios/Classes/EMPushManagerWrapper.m b/ios/Classes/EMPushManagerWrapper.m index d471d2d1..75f48373 100644 --- a/ios/Classes/EMPushManagerWrapper.m +++ b/ios/Classes/EMPushManagerWrapper.m @@ -26,23 +26,23 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { if ([EMMethodKeyGetImPushConfig isEqualToString:call.method]) { [self getImPushConfig:call.arguments - channelName:EMMethodKeyGetImPushConfig + channelName:call.method result:result]; } else if ([EMMethodKeyGetImPushConfigFromServer isEqualToString:call.method]) { [self getImPushConfigFromServer:call.arguments - channelName:EMMethodKeyGetImPushConfigFromServer + channelName:call.method result:result]; } else if ([EMMethodKeyUpdatePushNickname isEqualToString:call.method]) { [self updatePushNickname:call.arguments - channelName:EMMethodKeyUpdatePushNickname + channelName:call.method result:result]; } else if ([EMMethodKeyImPushNoDisturb isEqualToString:call.method]) { [self setImPushNoDisturb:call.arguments - channelName:EMMethodKeyImPushNoDisturb + channelName:call.method result:result]; } else if ([EMMethodKeyUpdateImPushStyle isEqualToString:call.method]) { [self updateImPushStyle:call.arguments - channelName:EMMethodKeyUpdateImPushStyle + channelName:call.method result:result]; } else if ([EMMethodKeyUpdateGroupPushService isEqualToString:call.method]) { [self updateGroupPushService:call.arguments @@ -50,11 +50,11 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:result]; } else if ([EMMethodKeyGetNoDisturbGroups isEqualToString:call.method]) { [self getNoDisturbGroups:call.arguments - channelName:EMMethodKeyGetNoDisturbGroups + channelName:call.method result:result]; } else if ([EMMethodKeyBindDeviceToken isEqualToString:call.method]) { [self bindDeviceToken:call.arguments - channelName:(NSString *)EMMethodKeyBindDeviceToken + channelName:call.method result:result]; } else{ diff --git a/ios/Classes/EMUserInfoManagerWrapper.m b/ios/Classes/EMUserInfoManagerWrapper.m index d24c9774..00bebf22 100644 --- a/ios/Classes/EMUserInfoManagerWrapper.m +++ b/ios/Classes/EMUserInfoManagerWrapper.m @@ -27,39 +27,45 @@ - (instancetype)initWithChannelName:(NSString *)aChannelName registrar:(NSObject #pragma mark - FlutterPlugin - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result { if ([call.method isEqualToString:EMMethodKeyUpdateOwnUserInfo]) { - [self updateOwnUserInfo:call.arguments result:result]; + [self updateOwnUserInfo:call.arguments channelName:call.method result:result]; } if ([call.method isEqualToString:EMMethodKeyUpdateOwnUserInfoWithType]) { - [self updateOwnUserInfoWithType:call.arguments result:result]; + [self updateOwnUserInfoWithType:call.arguments + channelName:call.method + result:result]; } if ([call.method isEqualToString:EMMethodKeyFetchUserInfoById]) { - [self fetchUserInfoById:call.arguments result:result]; + [self fetchUserInfoById:call.arguments + channelName:call.method + result:result]; } if ([call.method isEqualToString:EMMethodKeyFetchUserInfoByIdWithType]) { - [self fetchUserInfoByIdWithType:call.arguments result:result]; + [self fetchUserInfoByIdWithType:call.arguments + channelName:call.method + result:result]; } } -- (void)updateOwnUserInfo:(NSDictionary *)param result:(FlutterResult)result { +- (void)updateOwnUserInfo:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self)weakSelf = self; EMUserInfo *userInfo = [EMUserInfo fromJson:param[@"userInfo"]]; [EMClient.sharedClient.userInfoManager updateOwnUserInfo:userInfo completion:^(EMUserInfo *aUserInfo, EMError *aError) { NSDictionary *objDic = [aUserInfo toJson]; [weakSelf wrapperCallBack:result - channelName:EMMethodKeyUpdateOwnUserInfo + channelName:aChannelName error:aError object:objDic]; }]; } -- (void)updateOwnUserInfoWithType:(NSDictionary *)param result:(FlutterResult)result { +- (void)updateOwnUserInfoWithType:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self)weakSelf = self; int typeValue = [param[@"userInfoType"] intValue]; @@ -71,7 +77,7 @@ - (void)updateOwnUserInfoWithType:(NSDictionary *)param result:(FlutterResult)r NSDictionary *objDic = [aUserInfo toJson]; [weakSelf wrapperCallBack:result - channelName:EMMethodKeyUpdateOwnUserInfoWithType + channelName:aChannelName error:aError object:objDic]; }]; @@ -79,7 +85,7 @@ - (void)updateOwnUserInfoWithType:(NSDictionary *)param result:(FlutterResult)r } -- (void)fetchUserInfoById:(NSDictionary *)param result:(FlutterResult)result { +- (void)fetchUserInfoById:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self)weakSelf = self; NSArray *userIds = param[@"userIds"]; @@ -91,7 +97,7 @@ - (void)fetchUserInfoById:(NSDictionary *)param result:(FlutterResult)result { }]; [weakSelf wrapperCallBack:result - channelName:EMMethodKeyFetchUserInfoById + channelName:aChannelName error:aError object:[dic copy]]; }]; @@ -100,7 +106,7 @@ - (void)fetchUserInfoById:(NSDictionary *)param result:(FlutterResult)result { -- (void)fetchUserInfoByIdWithType:(NSDictionary *)param result:(FlutterResult)result { +- (void)fetchUserInfoByIdWithType:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result { __weak typeof(self)weakSelf = self; NSArray *userIds = param[@"userIds"]; NSArray *userInfoTypes = param[@"userInfoTypes"]; diff --git a/lib/im_flutter_sdk.dart b/lib/im_flutter_sdk.dart index 7858eb37..f8b6566b 100644 --- a/lib/im_flutter_sdk.dart +++ b/lib/im_flutter_sdk.dart @@ -14,6 +14,7 @@ export 'src/models/em_error.dart'; export 'src/models/em_group.dart'; export 'src/models/em_message.dart'; export 'src/models/em_options.dart'; -export 'src/models/em_push_config.dart'; +export 'src/models/em_push_configs.dart'; export 'src/models/em_page_result.dart'; export 'src/models/em_userInfo.dart'; +export 'src/models/em_group_shared_file.dart'; diff --git a/lib/src/em_group_manager.dart b/lib/src/em_group_manager.dart index ab815611..31123d9c 100644 --- a/lib/src/em_group_manager.dart +++ b/lib/src/em_group_manager.dart @@ -5,6 +5,7 @@ import 'em_listeners.dart'; import 'models/em_cursor_result.dart'; import 'models/em_error.dart'; import 'models/em_group.dart'; +import 'models/em_group_shared_file.dart'; import 'tools/em_extension.dart'; import 'chat_method_keys.dart'; diff --git a/lib/src/em_push_manager.dart b/lib/src/em_push_manager.dart index 34aa87a7..cfc11566 100644 --- a/lib/src/em_push_manager.dart +++ b/lib/src/em_push_manager.dart @@ -5,7 +5,7 @@ import 'package:flutter/services.dart'; import 'tools/em_extension.dart'; import 'chat_method_keys.dart'; import 'models/em_error.dart'; -import 'models/em_push_config.dart'; +import 'models/em_push_configs.dart'; class EMPushManager { static const _channelPrefix = 'com.chat.im'; @@ -13,23 +13,23 @@ class EMPushManager { '$_channelPrefix/chat_push_manager', JSONMethodCodec()); /// 从本地获取ImPushConfig - Future getImPushConfig() async { + Future getImPushConfig() async { Map result = await _channel.invokeMethod(ChatMethodKeys.getImPushConfig); try { EMError.hasErrorFromResult(result); - return EMImPushConfig.fromJson(result[ChatMethodKeys.getImPushConfig]); + return EMPushConfigs.fromJson(result[ChatMethodKeys.getImPushConfig]); } on EMError catch (e) { throw e; } } /// 从服务器获取ImPushConfig - Future getImPushConfigFromServer() async { + Future getImPushConfigFromServer() async { Map result = await _channel.invokeMethod(ChatMethodKeys.getImPushConfigFromServer); try { EMError.hasErrorFromResult(result); - return EMImPushConfig.fromJson( + return EMPushConfigs.fromJson( result[ChatMethodKeys.getImPushConfigFromServer]); } on EMError catch (e) { throw e; diff --git a/lib/src/models/em_chat_room.dart b/lib/src/models/em_chat_room.dart index 76278fe3..988ef9a3 100644 --- a/lib/src/models/em_chat_room.dart +++ b/lib/src/models/em_chat_room.dart @@ -14,17 +14,17 @@ class EMChatRoom { factory EMChatRoom.fromJson(Map map) { return EMChatRoom._private() - .._roomId = map['roomId'] as String? - .._name = map['name'] - .._description = map['desc'] - .._owner = map['owner'] - .._memberCount = map['memberCount'] - .._maxUsers = map['maxUsers'] - .._adminList = map['adminList'] - .._memberList = map['memberList'] - .._blockList = map['blockList'] - .._muteList = map['muteList'] - .._announcement = map['announcement'] + .._roomId = map['roomId'] as String + .._name = map.stringValue("name") + .._description = map.stringValue("desc") + .._owner = map.stringValue("owner") + .._memberCount = map.intValue("memberCount") + .._maxUsers = map.intValue("maxUsers") + .._adminList = map.listValue("adminList") + .._memberList = map.listValue("memberList") + .._blockList = map.listValue("blockList") + .._muteList = map.listValue("muteList") + .._announcement = map.stringValue("announcement") .._permissionType = EMChatRoom.permissionTypeFromInt(map['permissionType']) .._isAllMemberMuted = map.boolValue('isAllMemberMuted'); @@ -33,24 +33,24 @@ class EMChatRoom { Map toJson() { final Map data = new Map(); data['roomId'] = _roomId; - data['name'] = _name; - data['desc'] = _description; - data['owner'] = _owner; - data['memberCount'] = _memberCount; - data['maxUsers'] = _maxUsers; - data['adminList'] = _adminList; - data['memberList'] = _memberList; - data['blockList'] = _blockList; - data['muteList'] = _muteList; - data['announcement'] = _announcement; + data.setValueWithOutNull("name", _name); + data.setValueWithOutNull("desc", _description); + data.setValueWithOutNull("owner", owner); + data.setValueWithOutNull("memberCount", _memberCount); + data.setValueWithOutNull("maxUsers", _maxUsers); + data.setValueWithOutNull("adminList", _adminList); + data.setValueWithOutNull("memberList", _memberList); + data.setValueWithOutNull("blockList", _blockList); + data.setValueWithOutNull("muteList", _muteList); + data.setValueWithOutNull("announcement", _announcement); + data.setValueWithOutNull("isAllMemberMuted", _isAllMemberMuted); data['permissionType'] = EMChatRoom.permissionTypeToInt(_permissionType); - data['isAllMemberMuted'] = _isAllMemberMuted; return data; } // 房间id - String? _roomId = ''; + late String _roomId; // 房间名称 String? _name = ''; // 房间描述 @@ -76,7 +76,7 @@ class EMChatRoom { // 在聊天室中的角色 EMChatRoomPermissionType _permissionType = EMChatRoomPermissionType.None; - get roomId => _roomId; + String get roomId => _roomId; get name => _name; get description => _description; get owner => _owner; diff --git a/lib/src/models/em_conversation.dart b/lib/src/models/em_conversation.dart index b05d450d..579066db 100644 --- a/lib/src/models/em_conversation.dart +++ b/lib/src/models/em_conversation.dart @@ -48,10 +48,10 @@ class EMConversation { return data; } - String id = ''; - EMConversationType? type; + late String id; + late EMConversationType type; - int? _unreadCount; + int _unreadCount = 0; Map? _ext; String? _name; EMMessage? _latestMessage; @@ -95,7 +95,7 @@ extension EMConversationExtension on EMConversation { static const MethodChannel _emConversationChannel = const MethodChannel('com.chat.im/chat_conversation', JSONMethodCodec()); - int? get unreadCount { + int get unreadCount { return _unreadCount; } diff --git a/lib/src/models/em_error.dart b/lib/src/models/em_error.dart index 13a49eef..76c711dd 100644 --- a/lib/src/models/em_error.dart +++ b/lib/src/models/em_error.dart @@ -1,28 +1,23 @@ class EMError { - EMError._private([this._code, this._description]); + EMError._private([int? code, String? desc]) + : _code = code ?? 0, + _description = desc ?? ""; - int? _code = 0; - String? _description; + late int _code; + late String _description; - get code { + int get code { return _code; } - get description { + String get description { return _description; } factory EMError.fromJson(Map map) { - return EMError._private() - .._code = map['code'] - .._description = map['description']; + return EMError._private(map['code'], map['description']); } -// static EMError hasErrorFromResult(Map map) { -// EMError error = EMError.fromJson(map['error']); -// return error; -// } - static hasErrorFromResult(Map map) { if (map['error'] == null) { return; @@ -35,6 +30,6 @@ class EMError { @override String toString() { - return "code: " + _code.toString() + " desc: " + _description!; + return "code: " + code.toString() + " desc: " + description; } } diff --git a/lib/src/models/em_group.dart b/lib/src/models/em_group.dart index 4fa10e0d..922e13c8 100644 --- a/lib/src/models/em_group.dart +++ b/lib/src/models/em_group.dart @@ -18,16 +18,16 @@ class EMGroup { EMGroup._private(); late String _groupId; - String? _name = ''; + String? _name; String? _description = ''; String? _owner = ''; String? _announcement = ''; int? _memberCount; - List? _memberList; - List? _adminList; - List? _blockList; - List? _muteList; - List? _sharedFileList; + List? _memberList; + List? _adminList; + List? _blockList; + List? _muteList; + bool? _noticeEnable = true; bool? _messageBlocked = false; bool? _isAllMemberMuted = false; @@ -44,7 +44,6 @@ class EMGroup { List? get adminList => _adminList; List? get blockList => _blockList; List? get muteList => _muteList; - List? get sharedFileList => _sharedFileList; bool? get noticeEnable => _noticeEnable; bool? get messageBlocked => _messageBlocked; bool? get isAllMemberMuted => _isAllMemberMuted; @@ -54,16 +53,15 @@ class EMGroup { factory EMGroup.fromJson(Map map) { return EMGroup._private() .._groupId = map['groupId'] - .._name = map['name'] - .._description = map['desc'] - .._owner = map['owner'] - .._announcement = map['announcement'] + .._name = map.stringValue("name") + .._description = map.stringValue("desc") + .._owner = map.stringValue("owner") + .._announcement = map.stringValue("announcement") .._memberCount = map['memberCount'] - .._memberList = map['memberList'] - .._adminList = map['adminList'] - .._blockList = map['blockList'] - .._muteList = map['muteList'] - .._sharedFileList = map['sharedFileList'] + .._memberList = map.listValue("memberList") + .._adminList = map.listValue("adminList") + .._blockList = map.listValue("blockList") + .._muteList = map.listValue("muteList") .._noticeEnable = map.boolValue('noticeEnable') .._messageBlocked = map.boolValue('messageBlocked') .._isAllMemberMuted = map.boolValue('isAllMemberMuted') @@ -73,22 +71,23 @@ class EMGroup { Map toJson() { Map data = Map(); - data['id'] = _groupId; - data['name'] = _name; - data['desc'] = _description; - data['owner'] = _owner; - data['announcement'] = _announcement; - data['memberCount'] = _memberCount; - data['memberList'] = _memberList; - data['adminList'] = _adminList; - data['blockList'] = _blockList; - data['muteList'] = _muteList; - data['sharedFileList'] = _sharedFileList; - data['noticeEnable'] = _noticeEnable; - data['messageBlocked'] = _messageBlocked; - data['isAllMemberMuted'] = _isAllMemberMuted; - data['options'] = _options!.toJson(); - data['permissionType'] = EMGroup.permissionTypeToInt(_permissionType); + data.setValueWithOutNull("id", _groupId); + data.setValueWithOutNull("name", _name); + data.setValueWithOutNull("desc", _description); + data.setValueWithOutNull("owner", _owner); + data.setValueWithOutNull("announcement", _announcement); + data.setValueWithOutNull("memberCount", _memberCount); + data.setValueWithOutNull("memberList", _memberList); + data.setValueWithOutNull("adminList", _adminList); + data.setValueWithOutNull("blockList", _blockList); + data.setValueWithOutNull("muteList", _muteList); + data.setValueWithOutNull("owner", _owner); + data.setValueWithOutNull("noticeEnable", _noticeEnable); + data.setValueWithOutNull("messageBlocked", _messageBlocked); + data.setValueWithOutNull("isAllMemberMuted", _isAllMemberMuted); + data.setValueWithOutNull("options", _options?.toJson()); + data.setValueWithOutNull( + "permissionType", EMGroup.permissionTypeToInt(_permissionType)); return data; } @@ -254,38 +253,3 @@ class EMGroupOptions { return this.toJson().toString(); } } - -class EMGroupSharedFile { - EMGroupSharedFile._private(); - - String? _fileId; - String? _fileName; - String? _fileOwner; - int? _createTime; - int? _fileSize; - - String? get fileId => _fileId; - String? get fileName => _fileName; - String? get fileOwner => _fileOwner; - int? get createTime => _createTime; - int? get fileSize => _fileSize; - - factory EMGroupSharedFile.fromJson(Map? map) { - return EMGroupSharedFile._private() - .._fileId = map?["fileId"] - .._fileName = map?["name"] - .._fileOwner = map?["owner"] - .._createTime = map?["createTime"] - .._fileSize = map?["fileSize"]; - } - - Map toJson() { - Map data = Map(); - data['fileId'] = _fileId; - data['name'] = _fileName; - data['owner'] = _fileOwner; - data['createTime'] = _createTime; - data['fileSize'] = _fileSize; - return data; - } -} diff --git a/lib/src/models/em_group_shared_file.dart b/lib/src/models/em_group_shared_file.dart new file mode 100644 index 00000000..9f3e45b7 --- /dev/null +++ b/lib/src/models/em_group_shared_file.dart @@ -0,0 +1,36 @@ +import '../tools/em_extension.dart'; + +class EMGroupSharedFile { + EMGroupSharedFile._private(); + + String? _fileId; + String? _fileName; + String? _fileOwner; + int? _createTime; + int? _fileSize; + + String? get fileId => _fileId; + String? get fileName => _fileName; + String? get fileOwner => _fileOwner; + int? get createTime => _createTime; + int? get fileSize => _fileSize; + + factory EMGroupSharedFile.fromJson(Map? map) { + return EMGroupSharedFile._private() + .._fileId = map?["fileId"] + .._fileName = map?["name"] + .._fileOwner = map?["owner"] + .._createTime = map?["createTime"] + .._fileSize = map?["fileSize"]; + } + + Map toJson() { + Map data = Map(); + data.setValueWithOutNull("fileId", _fileId); + data.setValueWithOutNull("name", _fileName); + data.setValueWithOutNull("owner", _fileOwner); + data.setValueWithOutNull("createTime", _createTime); + data.setValueWithOutNull("fileSize", _fileSize); + return data; + } +} diff --git a/lib/src/models/em_options.dart b/lib/src/models/em_options.dart index 9cec9066..584d4e5d 100644 --- a/lib/src/models/em_options.dart +++ b/lib/src/models/em_options.dart @@ -1,4 +1,5 @@ import '../tools/em_extension.dart'; +import 'em_push_config.dart'; class EMOptions { /// 环信 appKey, 必须设置。 @@ -49,7 +50,7 @@ class EMOptions { bool? serverTransfer = true; bool? isAutoDownload = true; - EMPushConfig? pushConfig; + EMPushConfig _pushConfig = EMPushConfig(); bool? enableDNSConfig = true; String? dnsUrl = ''; @@ -57,6 +58,44 @@ class EMOptions { String? imServer = ''; int? imPort = 0; + /// 开启Oppo推送,`appkey`是Oppo的appkey,`secret`是Oppo的secret。申请流程访问 + /// `http://docs-im.easemob.com/im/android/push/thirdpartypush` + void enableOppPush(String appKey, String secret) { + _pushConfig.enableOppoPush = true; + _pushConfig.oppoAppKey = appKey; + _pushConfig.oppoAppSecret = secret; + } + + /// 开启小米推送, `appId`是推送用AppId, `appKey`是推送用AppKey。申请流程请访问 + /// `http://docs-im.easemob.com/im/android/push/thirdpartypush` + void enableMiPush(String appId, String appKey) { + _pushConfig.enableMiPush = true; + _pushConfig.miAppId = appId; + _pushConfig.miAppKey = appKey; + } + + void enableFCM(String appId) { + _pushConfig.enableFCM = true; + _pushConfig.fcmId = appId; + } + + void enableVivoPush() { + _pushConfig.enableVivoPush = true; + } + + /// 华为推送,具体流程请访问 + /// `http://docs-im.easemob.com/im/android/push/thirdpartypush` + void enableHWPush() { + _pushConfig.enableHWPush = true; + } + + /// 开启苹果推送,具体申请证书和上传流程请参考文档 + /// `http://docs-im.easemob.com/im/ios/apns/deploy` + void enableAPNs(String certName) { + _pushConfig.enableAPNS = true; + _pushConfig.apnsCertName = certName; + } + EMOptions({required this.appKey}); /// 设置自定义server地址 @@ -72,7 +111,7 @@ class EMOptions { } factory EMOptions.fromJson(Map json) { - return EMOptions(appKey: json['appKey']) + var ret = EMOptions(appKey: json['appKey']) ..autoLogin = json.boolValue('autoLogin') ..debugModel = json.boolValue('debugModel') ..requireAck = json.boolValue('requireAck') @@ -88,170 +127,51 @@ class EMOptions { json.boolValue('isChatRoomOwnerLeaveAllowed') ..serverTransfer = json.boolValue('serverTransfer') ..usingHttpsOnly = json.boolValue('usingHttpsOnly') - ..pushConfig = json['pushConfig'] != null - ? EMPushConfig.fromJson(json['pushConfig']) - : null ..enableDNSConfig = json.boolValue('enableDNSConfig') - ..imPort = json['imPort'] - ..imServer = json['imServer'] - ..restServer = json['restServer'] - ..dnsUrl = json['dnsUrl']; - } - - Map toJson() { - final Map data = new Map(); - data['appKey'] = this.appKey; - data['autoLogin'] = this.autoLogin; - data['debugModel'] = this.debugModel; - data['acceptInvitationAlways'] = this.acceptInvitationAlways; - data['autoAcceptGroupInvitation'] = this.autoAcceptGroupInvitation; - data['deleteMessagesAsExitGroup'] = this.deleteMessagesAsExitGroup; - data['deleteMessagesAsExitChatRoom'] = this.deleteMessagesAsExitChatRoom; - data['dnsUrl'] = this.dnsUrl; - data['enableDNSConfig'] = this.enableDNSConfig; - data['imPort'] = this.imPort; - data['imServer'] = this.imServer; - data['isAutoDownload'] = this.isAutoDownload; - data['isChatRoomOwnerLeaveAllowed'] = this.isChatRoomOwnerLeaveAllowed; - data['requireAck'] = this.requireAck; - data['requireDeliveryAck'] = this.requireDeliveryAck; - data['restServer'] = this.restServer; - data['serverTransfer'] = this.serverTransfer; - data['sortMessageByServerTime'] = this.sortMessageByServerTime; - data['usingHttpsOnly'] = this.usingHttpsOnly; - if (this.pushConfig != null) { - data['pushConfig'] = this.pushConfig!.toJson(); + ..imPort = json.intValue("imPort") + ..imServer = json.stringValue("imServer") + ..restServer = json.stringValue("restServer") + ..dnsUrl = json.stringValue("dnsUrl"); + ret._pushConfig = EMPushConfig(); + if (json['pushConfig'] != null) { + ret._pushConfig.updateFromJson(json); } - return data; - } - @override - String toString() { - return toJson().toString(); + return ret; } -} - -class EMPushConfig { - String? _mzAppId = ''; - String? _mzAppKey = ''; - - String? _oppoAppKey = ''; - String? _oppoAppSecret = ''; - - String? _miAppId = ''; - String? _miAppKey = ''; - - String? _fcmId = ''; - String? _apnsCertName = ''; - - bool? _enableMeiZuPush = false; - bool? _enableOppoPush = false; - bool? _enableMiPush = false; - - bool? _enableFCM = false; - - bool? _enableVivoPush = false; - bool? _enableHWPush = false; - - bool? _enableAPNS = false; - - /// 开启魅族推送, `appId`是推送用AppId, `appKey`是推送用AppKey。申请流程请访问 - /// `http://docs-im.easemob.com/im/android/push/thirdpartypush` - void enableMeiZuPush(String appId, String appKey) { - _enableMeiZuPush = true; - _mzAppId = appId; - _mzAppKey = appKey; - } - - /// 开启Oppo推送,`appkey`是Oppo的appkey,`secret`是Oppo的secret。申请流程访问 - /// `http://docs-im.easemob.com/im/android/push/thirdpartypush` - void enableOppPush(String appKey, String secret) { - _enableOppoPush = true; - _oppoAppKey = appKey; - _oppoAppSecret = secret; - } - - /// 开启小米推送, `appId`是推送用AppId, `appKey`是推送用AppKey。申请流程请访问 - /// `http://docs-im.easemob.com/im/android/push/thirdpartypush` - void enableMiPush(String appId, String appKey) { - _enableMiPush = true; - _miAppId = appId; - _miAppKey = appKey; - } - - void enableFCM(String appId) { - _enableFCM = true; - _fcmId = appId; - } - - void enableVivoPush() { - _enableVivoPush = true; - } - - /// 华为推送,具体流程请访问 - /// `http://docs-im.easemob.com/im/android/push/thirdpartypush` - void enableHWPush() { - _enableHWPush = true; - } - - /// 开启苹果推送,具体申请证书和上传流程请参考文档 - /// `http://docs-im.easemob.com/im/ios/apns/deploy` - void enableAPNs(String certName) { - _enableAPNS = true; - _apnsCertName = certName; - } - - EMPushConfig(); - - EMPushConfig._private(); - - factory EMPushConfig.fromJson(Map json) { - return EMPushConfig._private() - .._mzAppId = json['mzAppId'] - .._mzAppKey = json['mzAppKey'] - .._oppoAppKey = json['oppoAppKey'] - .._oppoAppSecret = json['oppoAppSecret'] - .._miAppId = json['miAppId'] - .._miAppKey = json['miAppKey'] - .._fcmId = json['fcmId'] - .._apnsCertName = json['apnsCertName'] - .._enableMeiZuPush = json.boolValue('enableMeiZuPush') - .._enableOppoPush = json.boolValue('enableOppoPush') - .._enableMiPush = json.boolValue('enableMiPush') - .._enableFCM = json.boolValue('enableFCM') - .._enableVivoPush = json.boolValue('enableVivoPush') - .._enableHWPush = json.boolValue('enableHWPush') - .._enableAPNS = json.boolValue('enableAPNS'); - } - - Map toJson() { - final Map data = new Map(); - - data['mzAppId'] = this._mzAppId; - data['mzAppKey'] = this._mzAppKey; - - data['oppoAppKey'] = this._oppoAppKey; - data['oppoAppSecret'] = this._oppoAppSecret; - - data['miAppId'] = this._miAppId; - data['miAppKey'] = this._miAppKey; - - data['fcmId'] = this._fcmId; - - data['apnsCertName'] = this._apnsCertName; - - data['enableMeiZuPush'] = this._enableMeiZuPush; - data['enableOppoPush'] = this._enableOppoPush; - data['enableMiPush'] = this._enableMiPush; - - data['enableFCM'] = this._enableFCM; - - data['enableHWPush'] = this._enableHWPush; - data['enableVivoPush'] = this._enableVivoPush; - - data['enableAPNS'] = this._enableAPNS; + Map toJson() { + Map data = new Map(); + data.setValueWithOutNull("appKey", appKey); + data.setValueWithOutNull("autoLogin", autoLogin); + data.setValueWithOutNull("debugModel", debugModel); + data.setValueWithOutNull("acceptInvitationAlways", acceptInvitationAlways); + data.setValueWithOutNull( + "autoAcceptGroupInvitation", + autoAcceptGroupInvitation, + ); + data.setValueWithOutNull( + "deleteMessagesAsExitGroup", deleteMessagesAsExitGroup); + data.setValueWithOutNull( + "deleteMessagesAsExitChatRoom", deleteMessagesAsExitChatRoom); + data.setValueWithOutNull("dnsUrl", dnsUrl); + data.setValueWithOutNull("enableDNSConfig", enableDNSConfig); + data.setValueWithOutNull("imPort", imPort); + data.setValueWithOutNull("imServer", imServer); + data.setValueWithOutNull("isAutoDownload", isAutoDownload); + data.setValueWithOutNull( + "isChatRoomOwnerLeaveAllowed", isChatRoomOwnerLeaveAllowed); + data.setValueWithOutNull("requireAck", requireAck); + data.setValueWithOutNull("requireDeliveryAck", requireDeliveryAck); + data.setValueWithOutNull("restServer", restServer); + data.setValueWithOutNull("serverTransfer", serverTransfer); + data.setValueWithOutNull( + "sortMessageByServerTime", sortMessageByServerTime); + data.setValueWithOutNull("usingHttpsOnly", usingHttpsOnly); + data['sortMessageByServerTime'] = this.sortMessageByServerTime; + data['usingHttpsOnly'] = this.usingHttpsOnly; + data['pushConfig'] = this._pushConfig.toJson(); return data; } diff --git a/lib/src/models/em_push_config.dart b/lib/src/models/em_push_config.dart index fdceccec..d7883be0 100644 --- a/lib/src/models/em_push_config.dart +++ b/lib/src/models/em_push_config.dart @@ -1,109 +1,73 @@ -import 'package:flutter/services.dart'; -import '../../im_flutter_sdk.dart'; -import '../chat_method_keys.dart'; import '../tools/em_extension.dart'; -enum EMImPushStyle { Simple, Summary } +class EMPushConfig { + String? mzAppId = ''; + String? mzAppKey = ''; -class EMImPushConfig { - EMImPushConfig._private(); + String? oppoAppKey = ''; + String? oppoAppSecret = ''; - EMImPushStyle? _pushStyle; - bool? _noDisturb; - int? _noDisturbStartHour; - int? _noDisturbEndHour; - List? _noDisturbGroups = []; + String? miAppId = ''; + String? miAppKey = ''; - EMImPushStyle? get pushStyle => _pushStyle; - bool? get noDisturb => _noDisturb; - int? get noDisturbStartHour => _noDisturbStartHour; - int? get noDisturbEndHour => _noDisturbEndHour; - List? get noDisturbGroups => _noDisturbGroups; + String? fcmId = ''; - factory EMImPushConfig.fromJson(Map map) { - return EMImPushConfig._private() - .._pushStyle = - map['pushStyle'] == 0 ? EMImPushStyle.Simple : EMImPushStyle.Summary - .._noDisturb = map.boolValue('noDisturb') - .._noDisturbStartHour = map['noDisturbStartHour'] - .._noDisturbEndHour = map['noDisturbEndHour']; - } + String? apnsCertName = ''; - Map toJson() { - Map data = Map(); - data['pushStyle'] = _pushStyle == EMImPushStyle.Simple; - data['noDisturb'] = _noDisturb; - data['noDisturbStartHour'] = _noDisturbStartHour; - data['noDisturbEndHour'] = _noDisturbEndHour; - return data; - } -} + bool? enableMeiZuPush = false; + bool? enableOppoPush = false; + bool? enableMiPush = false; -extension EMPushConfigExtension on EMImPushConfig { - // channel的命名与pushManager中的channel一致,本质上还是一个channel。 - static const MethodChannel _channel = - const MethodChannel('com.chat.im/chat_push_manager', JSONMethodCodec()); + bool? enableFCM = false; - /// 设置是否免打扰[isNoDisturb], [startTime], [endTime] - Future setNoDisturb( - bool isNoDisturb, [ - int startTime = 0, - int endTime = 24, - ]) async { - if (startTime < 0) startTime = 0; - if (endTime > 24) endTime = 24; - Map req = { - 'noDisturb': isNoDisturb, - 'startTime': startTime, - 'endTime': endTime - }; - Map result = - await _channel.invokeMethod(ChatMethodKeys.imPushNoDisturb, req); - EMError.hasErrorFromResult(result); - bool success = result.boolValue(ChatMethodKeys.imPushNoDisturb); - if (success) { - _noDisturb = isNoDisturb; - _noDisturbStartHour = startTime; - _noDisturbEndHour = endTime; - } - return success; - } + bool? enableVivoPush = false; + bool? enableHWPush = false; - /// 设置消息推送显示样式[pushStyle] - Future setPushStyle(EMImPushStyle pushStyle) async { - EMLog.v('setPushStyle: ' + pushStyle.toString()); - Map req = {'pushStyle': pushStyle == EMImPushStyle.Simple ? 0 : 1}; - Map result = - await _channel.invokeMethod(ChatMethodKeys.updateImPushStyle, req); - EMError.hasErrorFromResult(result); - bool success = result.boolValue(ChatMethodKeys.updateImPushStyle); - if (success) _pushStyle = pushStyle; - return success; + bool? enableAPNS = false; + + EMPushConfig(); + + void updateFromJson(Map json) { + miAppId = json['mzAppId']; + mzAppKey = json['mzAppKey']; + oppoAppKey = json['oppoAppKey']; + oppoAppSecret = json['oppoAppSecret']; + miAppId = json['miAppId']; + miAppKey = json['miAppKey']; + fcmId = json['fcmId']; + apnsCertName = json['apnsCertName']; + enableMeiZuPush = json.boolValue('enableMeiZuPush'); + enableOppoPush = json.boolValue('enableOppoPush'); + enableMiPush = json.boolValue('enableMiPush'); + enableFCM = json.boolValue('enableFCM'); + enableVivoPush = json.boolValue('enableVivoPush'); + enableHWPush = json.boolValue('enableHWPush'); + enableAPNS = json.boolValue('enableAPNS'); } - /// 通过群id[groupId]设置群组是否免打扰[isNoDisturb] - Future setGroupToDisturb( - String groupId, - bool isNoDisturb, - ) async { - Map req = {'noDisturb': isNoDisturb, 'group_id': groupId}; - EMLog.v('setGroupToDisturb: ' + req.toString()); - Map result = - await _channel.invokeMethod(ChatMethodKeys.updateGroupPushService, req); - EMError.hasErrorFromResult(result); - EMGroup group = - EMGroup.fromJson(result[ChatMethodKeys.updateGroupPushService]); - _noDisturbGroups!.removeWhere((e) => e == group.groupId); - if (isNoDisturb) _noDisturbGroups!.add(group.groupId); - return group; + Map toJson() { + final Map data = new Map(); + data.setValueWithOutNull("mzAppId", mzAppId); + data.setValueWithOutNull("mzAppKey", mzAppKey); + data.setValueWithOutNull("oppoAppKey", oppoAppKey); + data.setValueWithOutNull("oppoAppSecret", oppoAppSecret); + data.setValueWithOutNull("miAppId", miAppId); + data.setValueWithOutNull("miAppKey", miAppKey); + data.setValueWithOutNull("fcmId", fcmId); + data.setValueWithOutNull("apnsCertName", apnsCertName); + data.setValueWithOutNull("enableMeiZuPush", enableMeiZuPush); + data.setValueWithOutNull("enableOppoPush", enableOppoPush); + data.setValueWithOutNull("enableMiPush", enableMiPush); + data.setValueWithOutNull("enableFCM", enableFCM); + data.setValueWithOutNull("enableHWPush", enableHWPush); + data.setValueWithOutNull("enableVivoPush", enableVivoPush); + data.setValueWithOutNull("enableAPNS", enableAPNS); + + return data; } - /// 获取免打扰群组列表 - Future?> noDisturbGroupsFromServer() async { - Map result = await _channel.invokeMethod(ChatMethodKeys.getNoDisturbGroups); - EMError.hasErrorFromResult(result); - _noDisturbGroups = - result[ChatMethodKeys.getNoDisturbGroups]?.cast(); - return _noDisturbGroups; + @override + String toString() { + return toJson().toString(); } } diff --git a/lib/src/models/em_push_configs.dart b/lib/src/models/em_push_configs.dart new file mode 100644 index 00000000..1bd7d104 --- /dev/null +++ b/lib/src/models/em_push_configs.dart @@ -0,0 +1,109 @@ +import 'package:flutter/services.dart'; +import '../../im_flutter_sdk.dart'; +import '../chat_method_keys.dart'; +import '../tools/em_extension.dart'; + +enum EMImPushStyle { Simple, Summary } + +class EMPushConfigs { + EMPushConfigs._private(); + + EMImPushStyle? _pushStyle; + bool? _noDisturb; + int? _noDisturbStartHour; + int? _noDisturbEndHour; + List? _noDisturbGroups = []; + + EMImPushStyle? get pushStyle => _pushStyle; + bool? get noDisturb => _noDisturb; + int? get noDisturbStartHour => _noDisturbStartHour; + int? get noDisturbEndHour => _noDisturbEndHour; + List? get noDisturbGroups => _noDisturbGroups; + + factory EMPushConfigs.fromJson(Map map) { + return EMPushConfigs._private() + .._pushStyle = + map['pushStyle'] == 0 ? EMImPushStyle.Simple : EMImPushStyle.Summary + .._noDisturb = map.boolValue('noDisturb') + .._noDisturbStartHour = map['noDisturbStartHour'] + .._noDisturbEndHour = map['noDisturbEndHour']; + } + + Map toJson() { + Map data = Map(); + data['pushStyle'] = _pushStyle == EMImPushStyle.Simple; + data['noDisturb'] = _noDisturb; + data['noDisturbStartHour'] = _noDisturbStartHour; + data['noDisturbEndHour'] = _noDisturbEndHour; + return data; + } +} + +extension EMPushConfigsExtension on EMPushConfigs { + // channel的命名与pushManager中的channel一致,本质上还是一个channel。 + static const MethodChannel _channel = + const MethodChannel('com.chat.im/chat_push_manager', JSONMethodCodec()); + + /// 设置是否免打扰[isNoDisturb], [startTime], [endTime] + Future setNoDisturb( + bool isNoDisturb, [ + int startTime = 0, + int endTime = 24, + ]) async { + if (startTime < 0) startTime = 0; + if (endTime > 24) endTime = 24; + Map req = { + 'noDisturb': isNoDisturb, + 'startTime': startTime, + 'endTime': endTime + }; + Map result = + await _channel.invokeMethod(ChatMethodKeys.imPushNoDisturb, req); + EMError.hasErrorFromResult(result); + bool success = result.boolValue(ChatMethodKeys.imPushNoDisturb); + if (success) { + _noDisturb = isNoDisturb; + _noDisturbStartHour = startTime; + _noDisturbEndHour = endTime; + } + return success; + } + + /// 设置消息推送显示样式[pushStyle] + Future setPushStyle(EMImPushStyle pushStyle) async { + EMLog.v('setPushStyle: ' + pushStyle.toString()); + Map req = {'pushStyle': pushStyle == EMImPushStyle.Simple ? 0 : 1}; + Map result = + await _channel.invokeMethod(ChatMethodKeys.updateImPushStyle, req); + EMError.hasErrorFromResult(result); + bool success = result.boolValue(ChatMethodKeys.updateImPushStyle); + if (success) _pushStyle = pushStyle; + return success; + } + + /// 通过群id[groupId]设置群组是否免打扰[isNoDisturb] + Future setGroupToDisturb( + String groupId, + bool isNoDisturb, + ) async { + Map req = {'noDisturb': isNoDisturb, 'group_id': groupId}; + EMLog.v('setGroupToDisturb: ' + req.toString()); + Map result = + await _channel.invokeMethod(ChatMethodKeys.updateGroupPushService, req); + EMError.hasErrorFromResult(result); + EMGroup group = + EMGroup.fromJson(result[ChatMethodKeys.updateGroupPushService]); + _noDisturbGroups!.removeWhere((e) => e == group.groupId); + if (isNoDisturb) _noDisturbGroups!.add(group.groupId); + return group; + } + + /// 获取免打扰群组列表 + Future?> noDisturbGroupsFromServer() async { + Map result = await _channel.invokeMethod(ChatMethodKeys.getNoDisturbGroups); + EMError.hasErrorFromResult(result); + _noDisturbGroups = + result[ChatMethodKeys.getNoDisturbGroups]?.cast(); + return _noDisturbGroups; + } +} diff --git a/lib/src/tools/em_extension.dart b/lib/src/tools/em_extension.dart index 1ac2d527..25d631d8 100644 --- a/lib/src/tools/em_extension.dart +++ b/lib/src/tools/em_extension.dart @@ -1,4 +1,5 @@ // 思考: 是否要把所有格式转换的部分都放到这个extension中? +import '../models/em_group_shared_file.dart'; extension MapExtension on Map { bool boolValue(String key) { @@ -14,4 +15,56 @@ extension MapExtension on Map { return false; } } + + int? intValue(String key) { + if (this.containsKey(key)) { + return this[key]; + } else { + return null; + } + } + + String? stringValue(String key) { + if (this.containsKey(key)) { + return this[key]; + } else { + return null; + } + } + + List? listValue(String key) { + if (this.containsKey(key)) { + List obj = this[key]; + if (T is String) { + List strList = []; + for (var item in obj) { + strList.add(item); + } + return strList as List; + } else if (T is EMGroupSharedFile) { + List fileList = []; + for (var item in obj) { + var file = EMGroupSharedFile.fromJson(item); + fileList.add(file); + } + return fileList as List; + } + } else { + return null; + } + } +} + +extension MapWithoutNull on Map { + setValueWithOutNull(String key, T? value, + [Object Function(T object)? callback]) { + if (value != null) { + if (callback != null) { + Object v = callback(value); + this[key] = v; + } else { + this[key] = value; + } + } + } } diff --git a/pubspec.yaml b/pubspec.yaml index 1529f2af..e91ab8d7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: im_flutter_sdk description: Easemob IM flutter SDK. -version: 3.8.3+5 +version: 3.8.3+6 homepage: http://www.easemob.com/product/im environment: From 335c49043202834bbebc57f107f8e0487d85025e Mon Sep 17 00:00:00 2001 From: dujiepeng <347302029@qq.com> Date: Mon, 21 Mar 2022 19:18:23 +0800 Subject: [PATCH 3/5] change files. --- CHANGELOG.md | 2 +- example/lib/pages/chat/chat_page.dart | 4 +- lib/im_flutter_sdk.dart | 2 + lib/src/em_group_manager.dart | 1 + lib/src/models/em_chat_enums.dart | 18 +++++ lib/src/models/em_chat_room.dart | 8 +- lib/src/models/em_conversation.dart | 6 -- lib/src/models/em_deviceInfo.dart | 8 +- lib/src/models/em_group.dart | 110 +------------------------- lib/src/models/em_group_options.dart | 104 ++++++++++++++++++++++++ lib/src/models/em_push_config.dart | 14 ++-- 11 files changed, 139 insertions(+), 138 deletions(-) create mode 100644 lib/src/models/em_chat_enums.dart create mode 100644 lib/src/models/em_group_options.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ae03271..2580dfce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ - 修改EMImPushConfig为EMPushConfigs; - 删除EMOptions中的EMPushConfig.设置推送证书时直接调用EMOptions即可; - EMGroup中移除ShareFiles,如果需要获取共享文件,请调用Api: - ```EMClient.getInstance.groupManager.getGroupFileListFromServer(groupId)``` + `EMClient.getInstance.groupManager.getGroupFileListFromServer(groupId)` ## 3.8.3+5 diff --git a/example/lib/pages/chat/chat_page.dart b/example/lib/pages/chat/chat_page.dart index 8929f8af..f752b4ac 100644 --- a/example/lib/pages/chat/chat_page.dart +++ b/example/lib/pages/chat/chat_page.dart @@ -609,9 +609,7 @@ class _ChatPageState extends State @override void onGroupMessageRead(List groupMessageAcks) {} @override - void onChatRoomDestroyed(String roomId, String? roomName) { - // TODO: implement onChatRoomDestroyed - } + void onChatRoomDestroyed(String roomId, String? roomName) {} @override void onConversationRead(String from, String to) {} diff --git a/lib/im_flutter_sdk.dart b/lib/im_flutter_sdk.dart index f8b6566b..285793c6 100644 --- a/lib/im_flutter_sdk.dart +++ b/lib/im_flutter_sdk.dart @@ -18,3 +18,5 @@ export 'src/models/em_push_configs.dart'; export 'src/models/em_page_result.dart'; export 'src/models/em_userInfo.dart'; export 'src/models/em_group_shared_file.dart'; +export 'src/models/em_group_options.dart'; +export 'src/models/em_chat_enums.dart'; diff --git a/lib/src/em_group_manager.dart b/lib/src/em_group_manager.dart index 31123d9c..b47c6ecd 100644 --- a/lib/src/em_group_manager.dart +++ b/lib/src/em_group_manager.dart @@ -5,6 +5,7 @@ import 'em_listeners.dart'; import 'models/em_cursor_result.dart'; import 'models/em_error.dart'; import 'models/em_group.dart'; +import 'models/em_group_options.dart'; import 'models/em_group_shared_file.dart'; import 'tools/em_extension.dart'; diff --git a/lib/src/models/em_chat_enums.dart b/lib/src/models/em_chat_enums.dart new file mode 100644 index 00000000..fe52229a --- /dev/null +++ b/lib/src/models/em_chat_enums.dart @@ -0,0 +1,18 @@ +enum EMGroupStyle { + PrivateOnlyOwnerInvite, // 私有群,只有群主能邀请他人进群,被邀请人会收到邀请信息,同意后可入群; + PrivateMemberCanInvite, // 私有群,所有人都可以邀请他人进群,被邀请人会收到邀请信息,同意后可入群; + PublicJoinNeedApproval, // 公开群,可以通过获取公开群列表api取的,申请加入时需要管理员以上权限用户同意; + PublicOpenJoin, // 公开群,可以通过获取公开群列表api取的,可以直接进入; +} + +enum EMChatRoomPermissionType { + None, + Member, + Admin, + Owner, +} +enum EMConversationType { + Chat, // 单聊消息 + GroupChat, // 群聊消息 + ChatRoom, // 聊天室消息 +} diff --git a/lib/src/models/em_chat_room.dart b/lib/src/models/em_chat_room.dart index 988ef9a3..2259c86d 100644 --- a/lib/src/models/em_chat_room.dart +++ b/lib/src/models/em_chat_room.dart @@ -1,11 +1,5 @@ import '../../src/tools/em_extension.dart'; - -enum EMChatRoomPermissionType { - None, - Member, - Admin, - Owner, -} +import 'em_chat_enums.dart'; class EMChatRoom { EMChatRoom._private(); diff --git a/lib/src/models/em_conversation.dart b/lib/src/models/em_conversation.dart index 579066db..db35b30a 100644 --- a/lib/src/models/em_conversation.dart +++ b/lib/src/models/em_conversation.dart @@ -5,12 +5,6 @@ import '../tools/em_extension.dart'; import '../../im_flutter_sdk.dart'; import '../chat_method_keys.dart'; -enum EMConversationType { - Chat, // 单聊消息 - GroupChat, // 群聊消息 - ChatRoom, // 聊天室消息 -} - enum EMMessageSearchDirection { Up, Down } class EMConversation { diff --git a/lib/src/models/em_deviceInfo.dart b/lib/src/models/em_deviceInfo.dart index 93158b4d..04245b9f 100644 --- a/lib/src/models/em_deviceInfo.dart +++ b/lib/src/models/em_deviceInfo.dart @@ -1,8 +1,4 @@ - - class EMDeviceInfo { - - EMDeviceInfo._private(); Map toJson() { @@ -22,12 +18,14 @@ class EMDeviceInfo { /// 设备资源描述 String? get resource => _resource; + /// 设备的UUID String? get deviceUUID => _deviceUUID; + /// 设备名称 String? get deviceName => _deviceName; String? _resource; String? _deviceUUID; String? _deviceName; -} \ No newline at end of file +} diff --git a/lib/src/models/em_group.dart b/lib/src/models/em_group.dart index 922e13c8..a464b04a 100644 --- a/lib/src/models/em_group.dart +++ b/lib/src/models/em_group.dart @@ -1,11 +1,5 @@ import '../tools/em_extension.dart'; - -enum EMGroupStyle { - PrivateOnlyOwnerInvite, // 私有群,只有群主能邀请他人进群,被邀请人会收到邀请信息,同意后可入群; - PrivateMemberCanInvite, // 私有群,所有人都可以邀请他人进群,被邀请人会收到邀请信息,同意后可入群; - PublicJoinNeedApproval, // 公开群,可以通过获取公开群列表api取的,申请加入时需要管理员以上权限用户同意; - PublicOpenJoin, // 公开群,可以通过获取公开群列表api取的,可以直接进入; -} +import 'em_group_options.dart'; enum EMGroupPermissionType { None, @@ -151,105 +145,3 @@ class EMGroup { return this.toJson().toString(); } } - -class EMGroupOptions { - EMGroupOptions._private(); - - EMGroupOptions( - {required EMGroupStyle style, - int count = 200, - bool inviteNeedConfirm = false, - String extension = ''}) { - _style = style; - _maxCount = count; - _inviteNeedConfirm = inviteNeedConfirm; - _ext = extension; - } - - EMGroupStyle? _style; - int? _maxCount; - bool? _inviteNeedConfirm; - String? _ext; - - EMGroupStyle? get style => _style; - int? get maxCount => _maxCount; - bool? get inviteNeedConfirm => _inviteNeedConfirm; - String? get ext => _ext; - - factory EMGroupOptions.fromJson(Map? map) { - return EMGroupOptions._private() - .._style = EMGroupOptions.styleTypeFromInt(map?['style']) - .._maxCount = map?['maxCount'] - .._ext = map?['ext'] - .._inviteNeedConfirm = map?.boolValue('inviteNeedConfirm'); - } - - Map toJson() { - Map data = Map(); - data['style'] = EMGroupOptions.styleTypeToInt(_style); - data['maxCount'] = _maxCount; - data['inviteNeedConfirm'] = _inviteNeedConfirm; - data['ext'] = _ext; - return data; - } - - static EMGroupStyle styleTypeFromInt(int? type) { - EMGroupStyle ret = EMGroupStyle.PrivateOnlyOwnerInvite; - switch (type) { - case 0: - { - ret = EMGroupStyle.PrivateOnlyOwnerInvite; - } - break; - case 1: - { - ret = EMGroupStyle.PrivateMemberCanInvite; - } - break; - case 2: - { - ret = EMGroupStyle.PublicJoinNeedApproval; - } - break; - case 3: - { - ret = EMGroupStyle.PublicOpenJoin; - } - break; - } - return ret; - } - - static int styleTypeToInt(EMGroupStyle? type) { - int ret = 0; - if (type == null) return ret; - switch (type) { - case EMGroupStyle.PrivateOnlyOwnerInvite: - { - ret = 0; - } - break; - case EMGroupStyle.PrivateMemberCanInvite: - { - ret = 1; - } - break; - case EMGroupStyle.PublicJoinNeedApproval: - { - ret = 2; - } - break; - case EMGroupStyle.PublicOpenJoin: - { - ret = 3; - } - break; - } - return ret; - } - - @override - String toString() { - return this.toJson().toString(); - } -} diff --git a/lib/src/models/em_group_options.dart b/lib/src/models/em_group_options.dart new file mode 100644 index 00000000..f8fed8b0 --- /dev/null +++ b/lib/src/models/em_group_options.dart @@ -0,0 +1,104 @@ +import 'em_chat_enums.dart'; +import '../tools/em_extension.dart'; + +class EMGroupOptions { + EMGroupOptions._private(); + + EMGroupOptions( + {required EMGroupStyle style, + int count = 200, + bool inviteNeedConfirm = false, + String extension = ''}) { + _style = style; + _maxCount = count; + _inviteNeedConfirm = inviteNeedConfirm; + _ext = extension; + } + + EMGroupStyle? _style; + int? _maxCount; + bool? _inviteNeedConfirm; + String? _ext; + + EMGroupStyle? get style => _style; + int? get maxCount => _maxCount; + bool? get inviteNeedConfirm => _inviteNeedConfirm; + String? get ext => _ext; + + factory EMGroupOptions.fromJson(Map? map) { + return EMGroupOptions._private() + .._style = EMGroupOptions.styleTypeFromInt(map?['style']) + .._maxCount = map?['maxCount'] + .._ext = map?['ext'] + .._inviteNeedConfirm = map?.boolValue('inviteNeedConfirm'); + } + + Map toJson() { + Map data = Map(); + data['style'] = EMGroupOptions.styleTypeToInt(_style); + data['maxCount'] = _maxCount; + data['inviteNeedConfirm'] = _inviteNeedConfirm; + data['ext'] = _ext; + return data; + } + + static EMGroupStyle styleTypeFromInt(int? type) { + EMGroupStyle ret = EMGroupStyle.PrivateOnlyOwnerInvite; + switch (type) { + case 0: + { + ret = EMGroupStyle.PrivateOnlyOwnerInvite; + } + break; + case 1: + { + ret = EMGroupStyle.PrivateMemberCanInvite; + } + break; + case 2: + { + ret = EMGroupStyle.PublicJoinNeedApproval; + } + break; + case 3: + { + ret = EMGroupStyle.PublicOpenJoin; + } + break; + } + return ret; + } + + static int styleTypeToInt(EMGroupStyle? type) { + int ret = 0; + if (type == null) return ret; + switch (type) { + case EMGroupStyle.PrivateOnlyOwnerInvite: + { + ret = 0; + } + break; + case EMGroupStyle.PrivateMemberCanInvite: + { + ret = 1; + } + break; + case EMGroupStyle.PublicJoinNeedApproval: + { + ret = 2; + } + break; + case EMGroupStyle.PublicOpenJoin: + { + ret = 3; + } + break; + } + return ret; + } + + @override + String toString() { + return this.toJson().toString(); + } +} diff --git a/lib/src/models/em_push_config.dart b/lib/src/models/em_push_config.dart index d7883be0..df561db3 100644 --- a/lib/src/models/em_push_config.dart +++ b/lib/src/models/em_push_config.dart @@ -28,13 +28,13 @@ class EMPushConfig { EMPushConfig(); void updateFromJson(Map json) { - miAppId = json['mzAppId']; - mzAppKey = json['mzAppKey']; - oppoAppKey = json['oppoAppKey']; - oppoAppSecret = json['oppoAppSecret']; - miAppId = json['miAppId']; - miAppKey = json['miAppKey']; - fcmId = json['fcmId']; + miAppId = json.stringValue("mzAppId"); + mzAppKey = json.stringValue("mzAppKey"); + oppoAppKey = json.stringValue("oppoAppKey"); + oppoAppSecret = json.stringValue("oppoAppSecret"); + miAppId = json.stringValue("miAppId"); + miAppKey = json.stringValue("miAppKey"); + fcmId = json.stringValue("fcmId"); apnsCertName = json['apnsCertName']; enableMeiZuPush = json.boolValue('enableMeiZuPush'); enableOppoPush = json.boolValue('enableOppoPush'); From a75887adba376165385ea409bf73992ac1547106 Mon Sep 17 00:00:00 2001 From: dujiepeng <347302029@qq.com> Date: Wed, 23 Mar 2022 12:04:07 +0800 Subject: [PATCH 4/5] change files. --- example/lib/pages/chat/chat_input_bar.dart | 4 +++- example/lib/pages/chat/chat_items/chat_item.dart | 14 +++++++++----- example/lib/pages/chat/chat_page.dart | 12 +++++++++--- .../lib/pages/chatroom/chat_room_list_page.dart | 13 ++++++++++--- .../contacts/contact_friends_request_page.dart | 16 ++++++++++++---- example/lib/pages/contacts/contacts_page.dart | 16 ++++++++++++---- .../pages/conversations/conversations_page.dart | 8 ++++++-- example/lib/pages/group/group_info_page.dart | 9 ++++++--- example/lib/pages/group/joined_groups_page.dart | 14 ++++++++++---- example/lib/pages/group/public_groups_page.dart | 16 ++++++++++++---- 10 files changed, 89 insertions(+), 33 deletions(-) diff --git a/example/lib/pages/chat/chat_input_bar.dart b/example/lib/pages/chat/chat_input_bar.dart index 67b865da..f52b2c3a 100644 --- a/example/lib/pages/chat/chat_input_bar.dart +++ b/example/lib/pages/chat/chat_input_bar.dart @@ -405,7 +405,9 @@ class _ChatInputBarState extends State { void _updateInputBarType() { _showSendBtn = widget.textController?.text.length != 0; - setState(() {}); + if (mounted) { + setState(() {}); + } } } diff --git a/example/lib/pages/chat/chat_items/chat_item.dart b/example/lib/pages/chat/chat_items/chat_item.dart index 71ffe9af..848a1f18 100644 --- a/example/lib/pages/chat/chat_items/chat_item.dart +++ b/example/lib/pages/chat/chat_items/chat_item.dart @@ -230,7 +230,9 @@ class ChatItemState extends State implements EMMessageStatusListener { @override void onError(EMError error) { - setState(() {}); + if (mounted) { + setState(() {}); + } print('发送失败'); } @@ -241,8 +243,9 @@ class ChatItemState extends State implements EMMessageStatusListener { @override void onReadAck() { - setState(() {}); - print('收到已读回调'); + if (mounted) { + setState(() {}); + } } @override @@ -250,8 +253,9 @@ class ChatItemState extends State implements EMMessageStatusListener { @override void onSuccess() { - setState(() {}); - print('发送成功'); + if (mounted) { + setState(() {}); + } } _messageBubble() { diff --git a/example/lib/pages/chat/chat_page.dart b/example/lib/pages/chat/chat_page.dart index f752b4ac..6e3248ec 100644 --- a/example/lib/pages/chat/chat_page.dart +++ b/example/lib/pages/chat/chat_page.dart @@ -130,7 +130,9 @@ class _ChatPageState extends State if (_keyboardVisible) { _inputBarType = ChatInputBarType.normal; SystemChannels.textInput.invokeMethod('TextInput.hide'); - setState(() {}); + if (mounted) { + setState(() {}); + } } }, child: SafeArea( @@ -261,7 +263,9 @@ class _ChatPageState extends State onFaceTap: (expression) { _inputBarEditingController.text = _inputBarEditingController.text + '[${expression.name}]'; - setState(() {}); + if (mounted) { + setState(() {}); + } }, onDeleteTap: () { if (_inputBarEditingController.text.length > 0) { @@ -296,7 +300,9 @@ class _ChatPageState extends State /// 刷新View并滑动到最底部 _setStateAndMoreToListViewEnd() { - setState(() {}); + if (mounted) { + setState(() {}); + } Future.delayed(Duration(milliseconds: 100), () { _scrollController.jumpTo(_scrollController.position.maxScrollExtent); }); diff --git a/example/lib/pages/chatroom/chat_room_list_page.dart b/example/lib/pages/chatroom/chat_room_list_page.dart index 0748e40c..fcc51f02 100644 --- a/example/lib/pages/chatroom/chat_room_list_page.dart +++ b/example/lib/pages/chatroom/chat_room_list_page.dart @@ -43,7 +43,9 @@ class ChatRoomsListPagesState extends State { _searchName = text; if (_searchName.length == 0) { _searchedRoom = null; - setState(() {}); + if (mounted) { + setState(() {}); + } } }, style: TextStyle( @@ -162,11 +164,14 @@ class ChatRoomsListPagesState extends State { _isEnd = false; } } - setState(() {}); + SmartDialog.showToast('获取成功'); isMore ? _refreshController.loadComplete() : _refreshController.refreshCompleted(); + if (mounted) { + setState(() {}); + } } on EMError catch (e) { SmartDialog.showToast('获取失败$e'); isMore @@ -203,7 +208,9 @@ class ChatRoomsListPagesState extends State { SmartDialog.showToast('搜索失败: $e'); } finally { SmartDialog.dismiss(); - setState(() {}); + if (mounted) { + setState(() {}); + } } } } diff --git a/example/lib/pages/contacts/contact_friends_request_page.dart b/example/lib/pages/contacts/contact_friends_request_page.dart index ed0d4eb3..ee97c4f1 100644 --- a/example/lib/pages/contacts/contact_friends_request_page.dart +++ b/example/lib/pages/contacts/contact_friends_request_page.dart @@ -19,7 +19,9 @@ class ContactFriendsRequestPageState extends State { String? currentUser = EMClient.getInstance.currentUsername; if (currentUser != null) { SharePreferenceManager.load(currentUser, callback: () { - setState(() {}); + if (mounted) { + setState(() {}); + } }); } } @@ -39,7 +41,9 @@ class ContactFriendsRequestPageState extends State { TextButton( onPressed: () { SharePreferenceManager.removeAllRequest(); - setState(() {}); + if (mounted) { + setState(() {}); + } }, child: Text( '清空', @@ -104,7 +108,9 @@ class ContactFriendsRequestPageState extends State { reqestId, true, ); - setState(() {}); + if (mounted) { + setState(() {}); + } }, ), TextButton( @@ -121,7 +127,9 @@ class ContactFriendsRequestPageState extends State { reqestId, false, ); - setState(() {}); + if (mounted) { + setState(() {}); + } }, ), ], diff --git a/example/lib/pages/contacts/contacts_page.dart b/example/lib/pages/contacts/contacts_page.dart index fd95c197..fc6ccf7b 100644 --- a/example/lib/pages/contacts/contacts_page.dart +++ b/example/lib/pages/contacts/contacts_page.dart @@ -35,7 +35,9 @@ class ContactsPageState extends State String? currentUser = EMClient.getInstance.currentUsername; if (currentUser != null) { SharePreferenceManager.load(currentUser, callback: () { - setState(() {}); + if (mounted) { + setState(() {}); + } }); } } @@ -253,7 +255,9 @@ class ContactsPageState extends State SuspensionUtil.sortListBySuspensionTag(_contactList); SuspensionUtil.setShowSuspensionStatus(_contactList); _contactList.insertAll(0, _topList); - setState(() {}); + if (mounted) { + setState(() {}); + } } } @@ -274,7 +278,9 @@ class ContactsPageState extends State SuspensionUtil.sortListBySuspensionTag(_contactList); SuspensionUtil.setShowSuspensionStatus(_contactList); _contactList.insertAll(0, _topList); - setState(() {}); + if (mounted) { + setState(() {}); + } Future.delayed(Duration(seconds: 3)).then((value) { _fetchContactsFromServer(count); }); @@ -320,7 +326,9 @@ class ContactsPageState extends State void onContactInvited(String? userName, String? reason) { SharePreferenceManager.addRequest(userName!); _friendRequestCount = SharePreferenceManager.loadUnreadCount(); - setState(() {}); + if (mounted) { + setState(() {}); + } } @override diff --git a/example/lib/pages/conversations/conversations_page.dart b/example/lib/pages/conversations/conversations_page.dart index 2bdb313c..43cf0543 100644 --- a/example/lib/pages/conversations/conversations_page.dart +++ b/example/lib/pages/conversations/conversations_page.dart @@ -166,7 +166,9 @@ class ConversationPageState extends State } on Error { _refreshController.refreshFailed(); } finally { - setState(() {}); + if (mounted) { + setState(() {}); + } } } @@ -191,7 +193,9 @@ class ConversationPageState extends State _conversationsList.removeAt(index); } on Error { } finally { - setState(() {}); + if (mounted) { + setState(() {}); + } } } diff --git a/example/lib/pages/group/group_info_page.dart b/example/lib/pages/group/group_info_page.dart index d69b2dc1..8e33f352 100644 --- a/example/lib/pages/group/group_info_page.dart +++ b/example/lib/pages/group/group_info_page.dart @@ -164,10 +164,10 @@ class GroupInfoPageState extends State { ); } - _joinPublicGroup() { + _joinPublicGroup() async { try { SmartDialog.showLoading(msg: '加入中...'); - EMClient.getInstance.groupManager.joinPublicGroup(_group!.groupId); + await EMClient.getInstance.groupManager.joinPublicGroup(_group!.groupId); SmartDialog.showToast('加入成功'); } on EMError catch (e) { SmartDialog.showToast('加入失败: $e'); @@ -199,8 +199,11 @@ class GroupInfoPageState extends State { .getGroupSpecificationFromServer( widget.group.groupId, ); - setState(() {}); + SmartDialog.showToast('获取成功'); + if (mounted) { + setState(() {}); + } } on EMError catch (e) { SmartDialog.showToast('获取失败: $e'); } finally { diff --git a/example/lib/pages/group/joined_groups_page.dart b/example/lib/pages/group/joined_groups_page.dart index e1a9e232..0eaca992 100644 --- a/example/lib/pages/group/joined_groups_page.dart +++ b/example/lib/pages/group/joined_groups_page.dart @@ -232,7 +232,7 @@ class JoinedGroupsPageState extends State { } _loadJoinedGroups([bool isMore = false]) async { - print('_loadJoinedGroups'); + debugPrint('_loadJoinedGroups'); try { if (!isMore) { _pageNumber = 0; @@ -255,7 +255,9 @@ class JoinedGroupsPageState extends State { _groupsList.clear(); } _groupsList.addAll(groups); - setState(() {}); + if (mounted) { + setState(() {}); + } SmartDialog.showToast('获取成功'); isMore ? _refreshController.loadComplete() @@ -291,7 +293,9 @@ class JoinedGroupsPageState extends State { _searchName = std; if (std.length == 0) { _searchedGroups.clear(); - setState(() {}); + if (mounted) { + setState(() {}); + } return; } _searchedGroups.clear(); @@ -305,6 +309,8 @@ class JoinedGroupsPageState extends State { continue; } } - setState(() {}); + if (mounted) { + setState(() {}); + } } } diff --git a/example/lib/pages/group/public_groups_page.dart b/example/lib/pages/group/public_groups_page.dart index 4621dd10..f889bc2e 100644 --- a/example/lib/pages/group/public_groups_page.dart +++ b/example/lib/pages/group/public_groups_page.dart @@ -43,7 +43,9 @@ class PublicGroupsPageState extends State { _searchName = text; if (_searchName.length == 0) { _searchedGroup = null; - setState(() {}); + if (mounted) { + setState(() {}); + } } }, style: TextStyle( @@ -154,7 +156,9 @@ class PublicGroupsPageState extends State { // 返回数据小于pageSize,说明是最后一页 if (_pageSize > cursor.data!.length) { _isEnd = true; - setState(() {}); + if (mounted) { + setState(() {}); + } } } } on EMError catch (e) { @@ -178,8 +182,10 @@ class PublicGroupsPageState extends State { _cursor = cursor.cursor; _groupsList.clear(); _groupsList.addAll(cursor.data!); - setState(() {}); SmartDialog.showToast('获取成功'); + if (mounted) { + setState(() {}); + } } on EMError catch (e) { SmartDialog.showToast('获取失败$e'); _refreshController.refreshFailed(); @@ -203,7 +209,9 @@ class PublicGroupsPageState extends State { SmartDialog.showToast('搜索失败: $e'); } finally { SmartDialog.dismiss(); - setState(() {}); + if (mounted) { + setState(() {}); + } } } } From 12f09c0db5f8bdb3801f79f53244d8fc31e567f9 Mon Sep 17 00:00:00 2001 From: dujiepeng <347302029@qq.com> Date: Wed, 23 Mar 2022 12:16:10 +0800 Subject: [PATCH 5/5] update change file. --- CHANGELOG.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2580dfce..b7c3b919 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,16 @@ - 修改EMImPushConfig为EMPushConfigs; - 删除EMOptions中的EMPushConfig.设置推送证书时直接调用EMOptions即可; - EMGroup中移除ShareFiles,如果需要获取共享文件,请调用Api: - `EMClient.getInstance.groupManager.getGroupFileListFromServer(groupId)` + `EMClient.getInstance.groupManager.getGroupFileListFromServer(groupId)` +- 将isConnected和isLoginBefore、Token改为从原生获取; +- 修复安卓设置群组免打扰失效的问题; +- 修复获取公开群crash的问题; +- 修改throw error的逻辑; +- 修改构造文本消息时的方法,需要传入参数名; +- 修改部分原生方法逻辑; +- 调整项目目录结构; +- 将`onConversationRead`回调方法参数改为必选; +- ## 3.8.3+5