Merge pull request #8 from OpenIMSDK/android

Android
This commit is contained in:
hrxiang 2021-07-12 16:08:29 +08:00 committed by GitHub
commit 2197b1c78f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 45 additions and 18 deletions

View File

@ -1,15 +1,42 @@
# flutter_openim_sdk
A new Flutter project.
A Flutter im plugin.
## Getting Started
This project is a starting point for a Flutter
[plug-in package](https://flutter.dev/developing-packages/),
a specialized package that includes platform-specific implementation code for
Android and/or iOS.
#### 1初始化
```
var msgListener = AdvancedMsgListener();
/// 初始化SDK
OpenIM.iMManager
..initSDK(
platform: 0,
ipApi: 'Api接口地址',
ipWs: 'WebSocket地址',
dbPath: '数据库目录',
listener: new InitSDKListener(),
)
For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
/// 添加消息监听(移除消息监听: OpenIM.iMManager.messageManager.removeAdvancedMsgListener(msgListener))
..messageManager.addAdvancedMsgListener(msgListener)
/// 设置发送消息进度监听
..messageManager.setMsgSendProgressListener(MsgSendProgressListener())
/// 设置好友关系监听
..friendshipManager.setFriendshipListener(FriendshipListener())
/// 设置会话监听
..conversationManager.setConversationListener(ConversationListener())
/// 设置群监听
..groupManager.setGroupListener(GroupListener());
```
#### 2会话管理 OpenIM.iMManager.conversationManager
#### 3好友关系管理 OpenIM.iMManager.friendshipManager
#### 4消息管理 OpenIM.iMManager.messageManager
#### 5组管理 OpenIM.iMManager.groupManager

View File

@ -47,8 +47,4 @@ public class ConversationManager {
CommonUtil.isPinnedConversation(methodCall),
new BaseListener(result));
}
public void getTotalUnreadMsgCount(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getTotalUnreadMsgCount(new BaseListener(result));
}
}

View File

@ -135,4 +135,8 @@ public class MessageManager {
Open_im_sdk.createForwardMessage(
CommonUtil.getForwardMessage(methodCall)));
}
public void getTotalUnreadMsgCount(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getTotalUnreadMsgCount(new BaseListener(result));
}
}

View File

@ -5,7 +5,7 @@ class AdvancedMsgListener {
/// listener uniquely identifies
final String id;
AdvancedMsgListener({required this.id});
AdvancedMsgListener() : id = "id_${DateTime.now().microsecondsSinceEpoch}";
void onRecvNewMessage(Message msg) {}

View File

@ -66,10 +66,6 @@ class ConversationManager {
.then((value) => _printValue(value));
}
Future<dynamic> getTotalUnreadMsgCount() {
return _channel.invokeMethod('getTotalUnreadMsgCount', _buildParam({}));
}
static Map _buildParam(Map param) {
param["ManagerName"] = "conversationManager";
return param;

View File

@ -104,7 +104,7 @@ class IMManager {
case 'onReceiveJoinApplication':
groupManager.groupListener.onReceiveJoinApplication(
map['groupId'],
GroupMembersInfo.fromJson(_formatJson(map['opUser'])),
GroupMembersInfo.fromJson(_formatJson(map['member'])),
map['opReason'],
);
break;

View File

@ -198,6 +198,10 @@ class MessageManager {
.then((value) => _toObj(value));
}
Future<dynamic> getTotalUnreadMsgCount() {
return _channel.invokeMethod('getTotalUnreadMsgCount', _buildParam({}));
}
static Map _buildParam(Map param) {
param["ManagerName"] = "messageManager";
return param;