From e1a6ab3c79e35894990b9d125c929d6bd911d6c1 Mon Sep 17 00:00:00 2001 From: hrxiang Date: Mon, 20 Dec 2021 14:49:31 +0800 Subject: [PATCH] Upgrade --- .idea/dbnavigator.xml | 3 + README.zh-cn.md | 1204 +++++++++++++++++-------------- android/build.gradle | 2 +- lib/src/manager/im_manager.dart | 3 +- 4 files changed, 669 insertions(+), 543 deletions(-) diff --git a/.idea/dbnavigator.xml b/.idea/dbnavigator.xml index 5dec747..cafdf4a 100644 --- a/.idea/dbnavigator.xml +++ b/.idea/dbnavigator.xml @@ -50,6 +50,9 @@ + + + diff --git a/README.zh-cn.md b/README.zh-cn.md index 3008ac6..8a31944 100644 --- a/README.zh-cn.md +++ b/README.zh-cn.md @@ -1,41 +1,28 @@ -# 1. 初始化与登录 +# 1. 初始化与登录 ## 1.1. initSDK 初始化OpenIM SDK,设置SDK网络连接地址以及本地数据存放目录等。 ``` -OpenIM.iMManager.initSDK( - //参考IMPlatform类 - platform: Platform.isAndroid ? IMPlatform.android : IMPlatform.ios, - ipApi: '', - ipWs: '', - dbPath: '', - listener: OnInitSDKListener( - connecting: () { - // 正在连接到服务器 - }, - connectFailed: (code, error) { - // 连接服务器失败 - }, - connectSuccess: () { - // 已经成功连接到服务器 - }, - kickedOffline: () { - // 当前用户被踢下线 - }, - userSigExpired: () { - // 登录票据已经过期 - }, - selfInfoUpdated: (info) { - // 当前用户的资料发生了更新 - }, - ), - ); + OpenIM.iMManager.initSDK( + platform: 1, + ipApi: 'ipApi', + ipWs: 'ipWs', + dbPath: 'dbPath', + listener: OnInitSDKListener( + onConnectFailed: (int? code, String? errorMsg) {}, + onConnecting: () {}, + onConnectSuccess: () {}, + onKickedOffline: () {}, + onSelfInfoUpdated: (UserInfo info) {}, + onUserSigExpired: () {}, + ), + ); ``` - 参数说明: @@ -70,9 +57,15 @@ initSDK方法返回Future对象 futrue.then((value) => '初始化成功').catchError((e)=>'初始化失败') ``` +## 1.2. unInitSDK +取消初始化,一般用于在初始化后需要重新初始化 + +``` +OpenIM.iMManager.unInitSDK(); +``` -## 1.2. login +## 1.3. login 使用用户ID(uid)和token登录,uid来自于自身业务服务器,token需要业务服务器根据secret向OpenIM服务端交换获取。 @@ -95,9 +88,7 @@ login方法返回Future对象 futrue.then((value) => '登录成功').catchError((e)=>'登录失败') ``` - - -## 1.3. logout +## 1.4. logout 登出OpenIM,通常在切换账号的时候调用,清除登录态以及内存中的所有数据。 @@ -113,9 +104,7 @@ logout方法返回Future对象 futrue.then((value) => '登出成功').catchError((e)=>'登出失败') ``` - - -## 1.4. getLoginStatus +## 1.5. getLoginStatus 获取当前用户登录状态。 @@ -123,21 +112,7 @@ futrue.then((value) => '登出成功').catchError((e)=>'登出失败') OpenIM.iMManager.getLoginStatus(); ``` -- 返回值说明: - -getLoginStatus方法返回Future对象 - -``` -futrue.then((value){ - if(value == 101){ - // 登录成功 - } -}) -``` - - - -## 1.5. getLoginUid +## 1.6. getLoginUid 获取当前登录用户ID。 @@ -145,9 +120,7 @@ futrue.then((value){ var uid = await OpenIM.iMManager.getLoginUid() ``` - - -## 1.6. getLoginUserInfo +## 1.7. getLoginUserInfo 获取当前登录用户的信息 @@ -155,38 +128,38 @@ var uid = await OpenIM.iMManager.getLoginUid() var userInfo = await OpenIM.iMManager.getLoginUserInfo(); ``` - - -## 1.7. setSelfInfo +## 1.8. setSelfInfo 修改当前登录用户信息 ``` -var result = await OpenIM.iMManager.setSelfInfo(info) +var result = await OpenIM.iMManager.setSelfInfo() ``` 参数说明: -| 名称 | 类型 | 描述 | -| ---- | -------- | ------------ | -| info | UserInfo | 用户信息对象 | - +| 名称 | 类型 | 描述 | +| ------ | ------ | -------- | +| name | String | 用户名 | +| icon | String | 头像 | +| gender | int | 性别 | +| mobile | String | 手机号 | +| birth | String | 年龄 | +| email | String | 邮箱 | +| ex | String | 附加信息 | +## 1.9. enabledSDKLog -## 1.8. unInitSDK - -取消初始化,一般用于在初始化后需要重新初始化 +sdk日志管理 ``` -OpenIM.iMManager.unInitSDK(); +OpenIM.iMManager.enabledSDKLog(enabled: false); ``` # 2. 用户资料 - - ## 2.1. getUsersInfo 根据用户ID批量获取用户信息 @@ -211,501 +184,552 @@ List list = await OpenIM.iMManager.getUsersInfo(uidList); # 3. 消息 +## 3.1. addAdvancedMsgListener - -## 3.1. createTextMessage - -创建一条文字消息。 +添加消息监听 ``` -Message message = await OpenIM.iMManager.messageManager.createTextMessage( text: '这里是消息内容',) + OpenIM.iMManager.messageManager.addAdvancedMsgListener(OnAdvancedMsgListener( + onRecvC2CReadReceipt: (List list) {}, + onRecvMessageRevoked: (String msgId) {}, + onRecvNewMessage: (Message msg) {}, + )); ``` -- 参数说明: +| 事件回调 | 事件描述 | 推荐操作 | +| -------------------- | -------------- | ---------------- | +| onRecvMessageRevoked | 消息成功撤回 | 从界面移除消息 | +| onRecvC2CReadReceipt | 消息被阅读回执 | 将消息标记为已读 | +| onRecvNewMessage | 收到新消息 | 界面添加新消息 | -| 名称 | 类型 | 描述 | -| ---- | ------ | -------- | -| text | String | 消息内容 | - -返回值说明: - -| 类型 | 描述 | -| ---------------- | -------- | -| Future< Message> | 消息对象 | - - - -## 3.2. createTextAtMessage +## 3.2. setMsgSendProgressListener -创建一条@消息 +消息发送进度监听,主要用途:图片,视频,文件等上传进度监听。 ``` -Message message = await OpenIM.iMManager.messageManager.createTextAtMessage( text: '消息内容', atUidList: [uid1,uid2,...],); + OpenIM.iMManager.messageManager.setMsgSendProgressListener( + OnMsgSendProgressListener(onProgress: (String msgID, int progress) { + // 根据消息id(clientMsgID),判断图片等上传进度 + })); ``` -- 参数说明: - -| 名称 | 类型 | 描述 | -| --------- | ------------- | ---------------- | -| text | String | 消息内容 | -| atUidList | List< String> | 选择的用户id集合 | - +## 3.3. sendMessage - -## 3.3. createImageMessage - -创建图片消息 +发送消息 ``` -Message message = await OpenIM.iMManager.messageManager.createImageMessage( imagePath: '图片的相对路径',) +OpenIM.iMManager.messageManager.sendMessage( + message: message, + userID: userId, + groupID: groupId, +) +.then((value){ + // 发送成功 +}) +.catchError((e){ + // 发送失败 +}) ``` - 参数说明: -| 名称 | 类型 | 描述 | -| --------- | ------ | -------------- | -| imagePath | String | 图片的相对路径 | - -注:initSDK时传入了数据缓存路径,如路径:A,这时需要你将图片复制到A路径下后,如 A/pic/a.png路径,imagePath的值:“/pic/a.png”。 - +| 名称 | 类型 | 描述 | +| -------------- | ------- | ------------------ | +| message | Message | 创建的消息结构体 | +| userID | String | 单聊对象的用户id | +| groupID | String | 群聊id | +| onlineUserOnly | Bool | 是否仅在线用户接收 | +注:如果一对一聊天 userID不能为空。如果群聊天groupID不能为空。如果消息发送成功执行then方法,发送失败执行catchError方法。 -## 3.4. createImageMessageFromFullPath +## 3.4. getHistoryMessageList -创建图片消息(绝对路径) +获取聊天记录 ``` -Message message = await OpenIM.iMManager.messageManager.createImageMessageFromFullPath( imagePath: path,) +OpenIM.iMManager.messageManager.getHistoryMessageList( + userID: '单聊对象id', + groupID: '群聊群id', + count: '获取的条数', + startMsg:'从哪一个消息开始' +) ``` - 参数说明: -| 名称 | 类型 | 描述 | -| --------- | ------ | ------------------------ | -| imagePath | String | 图片在设备上的的绝对路径 | - -此方法不需要拷贝,推荐使用。 - +| 名称 | 类型 | 描述 | +| -------- | ------- | ---------------- | +| userID | String | 单聊对象的用户id | +| groupID | String | 群聊id | +| count | int | 拉取的条数 | +| startMsg | Message | 从哪一个消息开始 | +注:startMsg:如第一次拉取20条记录 startMsg=null && count=20 得到List< Message> list;下一次拉取消息记录参数:startMsg=list.first && count =20;以此内推,startMsg始终为list的第一条。 -## 3.5. createSoundMessage +## 3.5. revokeMessage -创建语音消息 +撤回消息 ``` -Message message = await OpenIM.iMManager.messageManager.createSoundMessage( soundPath: '相对路径', duration: '语音时长,单位秒',) +OpenIM.iMManager.messageManager.revokeMessage(message: message) ``` - 参数说明: -| 名称 | 类型 | 描述 | -| --------- | ------ | ---------------- | -| soundPath | String | 相对路径 | -| duration | int | 语音时长,单位秒 | - -注:initSDK时传入了数据缓存路径,如路径:A,这时需要你将语音文件复制到A路径下后,如 A/sound/a.m4a路径,soundPath的值:“/sound/a.m4a”。 - +| 名称 | 类型 | 描述 | +| ------- | ------- | -------------- | +| message | Message | 被撤回的消息体 | +注:调用此方法会触发消息撤回回调,可以在回调里移除界面上的消息显示。也会触发新增消息回调,新增的消息类型为撤回消息类型,可以在界面显示一条xx撤回了一条消息 -## 3.6. createSoundMessageFromFullPath +## 3.6. deleteMessageFromLocalStorage -创建语音消息(绝对路径) +删除本地消息。 ``` -Message message = await OpenIM.iMManager.messageManager.createSoundMessageFromFullPath( soundPath: '在设备上的的实际路径', duration: '语音时长,单位秒',) +OpenIM.iMManager.messageManager.deleteMessageFromLocalStorage(message); ``` - 参数说明: -| 名称 | 类型 | 描述 | -| --------- | ------ | -------------------- | -| soundPath | String | 在设备上的的绝对路径 | -| duration | int | 语音时长,单位秒 | - -此方法不需要拷贝,推荐使用。 - - +| 名称 | 类型 | 描述 | +| ------- | ------- | ---------------- | +| message | Message | 被删除的消息对象 | -## 3.7. createVideoMessage +## 3.7. insertSingleMessageToLocalStorage -创建视频消息 +插入一条消息到本地。 ``` -Message message = await OpenIM.iMManager.messageManager.createVideoMessage( videoPath: '相对路径', videoType: '文件的mineType', duration: '视频时长,单位秒', snapshotPath: '视频的缩略图', ) +OpenIM.iMManager.messageManager.insertSingleMessageToLocalStorage( + userID: '接收者ID', + message: '消息结构体', + sender: '发送者ID' +) ``` - 参数说明: -| 名称 | 类型 | 描述 | -| ------------ | ------ | ---------------- | -| videoPath | String | 相对路径 | -| videoType | String | 文件的mineType | -| duration | int | 视频时长,单位秒 | -| snapshotPath | String | 视频的缩略图 | - -注:initSDK时传入了数据缓存路径,如路径:A,这时需要你将视频文件复制到A路径下后,如 A/video/a.mp4路径,videoPath的值:“/video/a.mp4” - - +| 名称 | 类型 | 描述 | +| -------- | ------- | ---------- | +| recevier | String | 接收者ID | +| sender | String | 发送者ID | +| message | Message | 消息结构体 | -## 3.8. createVideoMessageFromFullPath +## 3.8. findMessages -创建视频消息(绝对路径) +根据消息ID查找本地消息。 ``` -Message message = await OpenIM.iMManager.messageManager.createVideoMessageFromFullPath( videoPath: '在设备上的的实际路径', videoType: '文件的mineType', duration: '视频时长,单位秒', snapshotPath: '视频的缩略图',) +OpenIM.iMManager.messageManager.findMessages(messageIDList: [id1,di2]) ``` - 参数说明: -| 名称 | 类型 | 描述 | -| ------------ | ------ | -------------------- | -| videoPath | String | 在设备上的的绝对路径 | -| videoType | String | 文件的mineType | -| duration | int | 视频时长,单位秒 | -| snapshotPath | String | 视频的缩略图 | - -此方法不需要拷贝,推荐使用。 - - +| 名称 | 类型 | 描述 | +| ------------- | ------------- | ------------------------- | +| messageIDList | List< String> | 消息id(clientMsgID)集合 | -## 3.9. createFileMessage +## 3.9. markC2CMessageAsRead -创建文件消息 +标记接收的消息为已读 ``` -Message message = await OpenIM.iMManager.messageManager.createFileMessage( filePath: '相对路径', fileName: '文件名',); +OpenIM.iMManager.messageManager.markC2CMessageAsRead( + userID: userID, + messageIDList: [msgId1,msgId2,..], +) ``` - 参数说明: -| 名称 | 类型 | 描述 | -| -------- | ------ | -------- | -| filePath | String | 相对路径 | -| fileName | String | 文件名 | - -注:initSDK时传入了数据缓存路径,如路径:A,这时需要你将视频文件复制到A路径下后,如 A/file/a.txt路径,filePath的值:“/file/a.txt” - +| 名称 | 类型 | 描述 | +| ------------- | ------------- | ------------------------ | +| userID | String | 单聊对象的用户id | +| messageIDList | List< String> | 被标记为已读消息的消息id | +注:单聊使用此功能,调用此方法会触发对方的c2c消息已读回调,可以在回调里修改界面上的消息已读状态 -## 3.10. createFileMessageFromFullPath +## 3.10. typingStatusUpdate -创建文件消息(绝对路径) +提示用户正在输入 ``` -Message message = await OpenIM.iMManager.messageManager.createFileMessageFromFullPath( filePath: '在设备上的的绝对路径', fileName: '文件名',) +OpenIM.iMManager.messageManager.typingStatusUpdate( + userID: uid, + typing: true, +) ``` - 参数说明: -| 名称 | 类型 | 描述 | -| -------- | ------ | -------------------- | -| filePath | String | 在设备上的的绝对路径 | -| fileName | String | 文件名 | - -此方法不需要拷贝,推荐使用。 - +| 名称 | 类型 | 描述 | +| ------ | ------ | ----------------------------------- | +| userID | String | 单聊对象的用户id | +| typing | Bool | typing:true正在输入,false停止输入 | +注:单聊使用此功能,在收到的新消息回调里如果消息类型为typing消息且typing == 'yes'提示正在输入。typing=='no'取消提示 -## 3.11. createLocationMessage +## 3.11. createTextMessage -创建位置消息 +创建一条文字消息。 ``` -Message message = await OpenIM.iMManager.messageManager.createLocationMessage( latitude: ’纬度‘, longitude: ’经度‘, description: ’描述信息,可以根据自己的需求传任何数据‘,) +Message message = await OpenIM.iMManager.messageManager.createTextMessage( + text: '这里是消息内容', +) ``` - 参数说明: -| 名称 | 类型 | 描述 | -| ----------- | ------ | -------------------------------------- | -| latitude | double | 纬度 | -| longitude | double | 经度 | -| description | String | 描述信息,可以根据自己的需求传任何数据 | - -description:在位置消息展示时,有位置名,位置描述,定位图片信息。推荐 description:{"title":"天府新谷","detail":"四川省高新区石羊街道府城大道西段399号","url":"https://apis.map.qq.com/ws/staticmap/v2/?center=%s&zoom=18&size=600*300&maptype=roadmap&markers=size:large|color:0xFFCCFF|label:k|%s&key=TMNBZ-3CGC6-C6SSL-EJA3B-E2P5Q-V7F6Q"} +| 名称 | 类型 | 描述 | +| ---- | ------ | -------- | +| text | String | 消息内容 | +返回值说明: +| 类型 | 描述 | +| ---------------- | -------- | +| Future< Message> | 消息对象 | -## 3.12. createQuoteMessage +## 3.12. createTextAtMessage -创建引用消息 +创建一条@消息 ``` -Message message = await OpenIM.iMManager.messageManager.createQuoteMessage( text: '消息内容', quoteMsg: '被引用的消息对象Message',) +Message message = await OpenIM.iMManager.messageManager.createTextAtMessage( + text: '消息内容', + atUidList: [uid1,uid2,...], +); ``` - 参数说明: -| 名称 | 类型 | 描述 | -| -------- | ----------- | ----------------------- | -| text | String | 消息内容 | -| quoteMsg | Message对象 | 被引用的消息对象Message | - - +| 名称 | 类型 | 描述 | +| --------- | ------------- | ---------------- | +| text | String | 消息内容 | +| atUidList | List< String> | 选择的用户id集合 | -## 3.13. createCardMessage +## 3.13. createImageMessage -创建名片消息 +创建图片消息 ``` -Message message = await OpenIM.iMManager.messageManager.createCardMessage( data: '用户信息Map',) +Message message = await OpenIM.iMManager.messageManager.createImageMessage( + imagePath: '图片的相对路径', +) ``` - 参数说明: -| 名称 | 类型 | 描述 | -| ---- | ---- | ------------------------------------------------------------ | -| data | Map | 如{"uid": uid, 'name': name, 'icon': icon},按需求自定义内容。 | - +| 名称 | 类型 | 描述 | +| --------- | ------ | -------------- | +| imagePath | String | 图片的相对路径 | +注:initSDK时传入了数据缓存路径,如路径:A,这时需要你将图片复制到A路径下后,如 A/pic/a.png路径,imagePath的值:“/pic/a.png”。 -## 3.14. createMergerMessage +## 3.14. createImageMessageFromFullPath -创建合并消息 +创建图片消息(绝对路径) ``` -Message message = await OpenIM.iMManager.messageManager.createMergerMessage( messageList: '被选中的消息', title: '标题', summaryList: '摘要',) +Message message = await OpenIM.iMManager.messageManager.createImageMessageFromFullPath( + imagePath: path, +) ``` - 参数说明: -| 名称 | 类型 | 描述 | -| ----------- | -------------- | ---------------- | -| title | String | 标题 | -| summaryList | List< String> | 摘要 | -| messageList | List< Message> | 被选中的消息集合 | - +| 名称 | 类型 | 描述 | +| --------- | ------ | ------------------------ | +| imagePath | String | 图片在设备上的的绝对路径 | +此方法不需要拷贝,推荐使用。 -## 3.15. createForwardMessage +## 3.15. createSoundMessage -创建转发消息 +创建语音消息 ``` -Message message = await OpenIM.iMManager.messageManager.createForwardMessage( message: '被转发的Message',) +Message message = await OpenIM.iMManager.messageManager.createSoundMessage( + soundPath: '相对路径', + duration: '语音时长,单位秒', +) ``` - 参数说明: -| 名称 | 类型 | 描述 | -| ------- | ------- | ----------------------- | -| message | Message | 被选择转发的Message对象 | - +| 名称 | 类型 | 描述 | +| --------- | ------ | ---------------- | +| soundPath | String | 相对路径 | +| duration | int | 语音时长,单位秒 | +注:initSDK时传入了数据缓存路径,如路径:A,这时需要你将语音文件复制到A路径下后,如 A/sound/a.m4a路径,soundPath的值:“/sound/a.m4a”。 -## 3.16. createCustomMessage +## 3.16. createSoundMessageFromFullPath -创建自定义消息 +创建语音消息(绝对路径) ``` -OpenIM.iMManager.messageManager.createCustomMessage( data: '自定义数据', extension: '自定义数据', description: '自定义数据', ) +Message message = await OpenIM.iMManager.messageManager.createSoundMessageFromFullPath( + soundPath: '在设备上的的实际路径', + duration: '语音时长,单位秒', +) ``` - 参数说明: -| 名称 | 类型 | 描述 | -| ----------- | --------- | -------------- | -| data | Uint8List | 自定义数据数组 | -| extension | Uint8List | 自定义数据数组 | -| description | String | 自定义数据 | - +| 名称 | 类型 | 描述 | +| --------- | ------ | -------------------- | +| soundPath | String | 在设备上的的绝对路径 | +| duration | int | 语音时长,单位秒 | +此方法不需要拷贝,推荐使用。 -## 3.17. sendMessage +## 3.17. createVideoMessage -发送消息 +创建视频消息 ``` -OpenIM.iMManager.messageManager .sendMessage( message: message, userID: userId, groupID: groupId, ) .then((value){ // 发送成功 }) .catchError((e){ // 发送失败 }) +Message message = await OpenIM.iMManager.messageManager.createVideoMessage( + videoPath: '相对路径', + videoType: '文件的mineType', + duration: '视频时长,单位秒', + snapshotPath: '视频的缩略图', +) ``` - 参数说明: -| 名称 | 类型 | 描述 | -| -------------- | ------- | ------------------ | -| message | Message | 创建的消息结构体 | -| userID | String | 单聊对象的用户id | -| groupID | String | 群聊id | -| onlineUserOnly | Bool | 是否仅在线用户接收 | - -注:如果一对一聊天 userID不能为空。如果群聊天groupID不能为空。如果消息发送成功执行then方法,发送失败执行catchError方法。 - +| 名称 | 类型 | 描述 | +| ------------ | ------ | ---------------- | +| videoPath | String | 相对路径 | +| videoType | String | 文件的mineType | +| duration | int | 视频时长,单位秒 | +| snapshotPath | String | 视频的缩略图 | +注:initSDK时传入了数据缓存路径,如路径:A,这时需要你将视频文件复制到A路径下后,如 A/video/a.mp4路径,videoPath的值:“/video/a.mp4” -## 3.18. typingStatusUpdate +## 3.18. createVideoMessageFromFullPath -提示用户正在输入 +创建视频消息(绝对路径) ``` -OpenIM.iMManager.messageManager.typingStatusUpdate( userID: uid, typing: true,) +Message message = await OpenIM.iMManager.messageManager.createVideoMessageFromFullPath( + videoPath: '在设备上的的实际路径', + videoType: '文件的mineType', + duration: '视频时长,单位秒', + snapshotPath: '视频的缩略图', +) ``` - 参数说明: -| 名称 | 类型 | 描述 | -| ------ | ------ | ----------------------------------- | -| userID | String | 单聊对象的用户id | -| typing | Bool | typing:true正在输入,false停止输入 | - -注:单聊使用此功能,在收到的新消息回调里如果消息类型为typing消息且typing == 'yes'提示正在输入。typing=='no'取消提示 - +| 名称 | 类型 | 描述 | +| ------------ | ------ | -------------------- | +| videoPath | String | 在设备上的的绝对路径 | +| videoType | String | 文件的mineType | +| duration | int | 视频时长,单位秒 | +| snapshotPath | String | 视频的缩略图 | +此方法不需要拷贝,推荐使用。 -## 3.19. revokeMessage +## 3.19. createFileMessage -撤回消息 +创建文件消息 ``` -OpenIM.iMManager.messageManager.revokeMessage(message: message) +Message message = await OpenIM.iMManager.messageManager.createFileMessage( + filePath: '相对路径', + fileName: '文件名', +); ``` - 参数说明: -| 名称 | 类型 | 描述 | -| ------- | ------- | -------------- | -| message | Message | 被撤回的消息体 | - -注:调用此方法会触发消息撤回回调,可以在回调里移除界面上的消息显示。也会触发新增消息回调,新增的消息类型为撤回消息类型,可以在界面显示一条xx撤回了一条消息 - +| 名称 | 类型 | 描述 | +| -------- | ------ | -------- | +| filePath | String | 相对路径 | +| fileName | String | 文件名 | +注:initSDK时传入了数据缓存路径,如路径:A,这时需要你将视频文件复制到A路径下后,如 A/file/a.txt路径,filePath的值:“/file/a.txt” -## 3.20. markC2CMessageAsRead +## 3.20. createFileMessageFromFullPath -标记接收的消息为已读 +创建文件消息(绝对路径) ``` -OpenIM.iMManager.messageManager.markC2CMessageAsRead( userID: userID, messageIDList: [msgId1,msgId2,..],) +Message message = await OpenIM.iMManager.messageManager.createFileMessageFromFullPath( + filePath: '在设备上的的绝对路径', + fileName: '文件名', +) ``` - 参数说明: -| 名称 | 类型 | 描述 | -| ------------- | ------------- | ------------------------ | -| userID | String | 单聊对象的用户id | -| messageIDList | List< String> | 被标记为已读消息的消息id | - -注:单聊使用此功能,调用此方法会触发对方的c2c消息已读回调,可以在回调里修改界面上的消息已读状态 - +| 名称 | 类型 | 描述 | +| -------- | ------ | -------------------- | +| filePath | String | 在设备上的的绝对路径 | +| fileName | String | 文件名 | +此方法不需要拷贝,推荐使用。 -## 3.21. getHistoryMessageList +## 3.21. createMergerMessage -获取聊天记录 +创建合并消息 ``` -OpenIM.iMManager.messageManager .getHistoryMessageList( userID: '单聊对象id', groupID: '群聊群id', count: '获取的条数', startMsg:'从哪一个消息开始' ) +Message message = await OpenIM.iMManager.messageManager.createMergerMessage( + messageList: '被选中的消息', + title: '标题', + summaryList: '摘要', +) ``` - 参数说明: -| 名称 | 类型 | 描述 | -| -------- | ------- | ---------------- | -| userID | String | 单聊对象的用户id | -| groupID | String | 群聊id | -| count | int | 拉取的条数 | -| startMsg | Message | 从哪一个消息开始 | - -注:startMsg:如第一次拉取20条记录 startMsg=null && count=20 得到List< Message> list;下一次拉取消息记录参数:startMsg=list.first && count =20;以此内推,startMsg始终为list的第一条。 - - +| 名称 | 类型 | 描述 | +| ----------- | -------------- | ---------------- | +| title | String | 标题 | +| summaryList | List< String> | 摘要 | +| messageList | List< Message> | 被选中的消息集合 | -## 3.22. addAdvancedMsgListener +## 3.22. createForwardMessage -添加消息监听 +创建转发消息 ``` -// 创建监听var listener = OnAdvancedMsgListener( recvMessageRevoked: (msgId){ // 消息被撤回回调 var revokedMsg = Message(clientMsgID: msgId); messageList.remove(revokedMsg); }, recvC2CReadReceipt: (List list){ // 消息已读回执 messageList.forEach((e) { // 获取当前聊天窗口的已读回执 var info = list.firstWhere((element) => element.uid == uid); // 标记消息列表里对应的消息为已读状态 if (info.msgIDList?.contains(e.clientMsgID) == true) { e.isRead = true; } }); }, recvNewMessage: (msg){ // 如果是当前窗口的消息 if (isCurrentChat(message)) { // 正在输入消息 if (message.contentType == MessageType.typing) { // } else { // 新增消息 if (!messageList.contains(message)) { messageList.add(message); } } } },)// 添加监听OpenIM.iMManager.messageManager.addAdvancedMsgListener(listener); +Message message = await OpenIM.iMManager.messageManager.createForwardMessage( + message: '被转发的Message', +) ``` -| 事件回调 | 事件描述 | 推荐操作 | -| ------------------ | -------------- | ---------------- | -| recvMessageRevoked | 消息成功撤回 | 从界面移除消息 | -| recvC2CReadReceipt | 消息被阅读回执 | 将消息标记为已读 | -| recvNewMessage | 收到新消息 | 界面添加新消息 | - +- 参数说明: +| 名称 | 类型 | 描述 | +| ------- | ------- | ----------------------- | +| message | Message | 被选择转发的Message对象 | -## 3.23. removeAdvancedMsgListener +## 3.23. createLocationMessage -移除消息监听 +创建位置消息 ``` -OpenIM.iMManager.messageManager.removeAdvancedMsgListener(listener); +Message message = await OpenIM.iMManager.messageManager.createLocationMessage( + latitude: ’纬度‘, + longitude: ’经度‘, + description: ’描述信息,可以根据自己的需求传任何数据‘, +) ``` - 参数说明: -| 名称 | 类型 | 描述 | -| -------- | ------------------------- | -------------------------- | -| listener | OnAdvancedMsgListener对象 | listener为3.22中创建的实例 | - +| 名称 | 类型 | 描述 | +| ----------- | ------ | -------------------------------------- | +| latitude | double | 纬度 | +| longitude | double | 经度 | +| description | String | 描述信息,可以根据自己的需求传任何数据 | +description:在位置消息展示时,有位置名,位置描述,定位图片信息。推荐 description:{"title":"天府新谷","detail":"四川省高新区石羊街道府城大道西段399号","url":"https://apis.map.qq.com/ws/staticmap/v2/?center=%s&zoom=18&size=600*300&maptype=roadmap&markers=size:large|color:0xFFCCFF|label:k|%s&key=TMNBZ-3CGC6-C6SSL-EJA3B-E2P5Q-V7F6Q"} -## 3.24. setMsgSendProgressListener +## 3.24. createCustomMessage -消息发送进度监听,主要用途:图片,视频,文件等上传进度监听。 +创建自定义消息 ``` -OpenIM.iMManager.messageManager.setMsgSendProgressListener(OnMsgSendProgressListener( progressCallback: (String msgId, int progress){ // 根据消息id(clientMsgID),判断图片等上传进度 },)) +OpenIM.iMManager.messageManager.createCustomMessage( + data: '自定义数据', + extension: '自定义数据', + description: '自定义数据', +) ``` +- 参数说明: +| 名称 | 类型 | 描述 | +| ----------- | ------ | -------------- | +| data | String | 自定义数据数组 | +| extension | String | 自定义数据数组 | +| description | String | 自定义数据 | -## 3.25. deleteMessageFromLocalStorage +## 3.25. createQuoteMessage -删除本地消息。 +创建引用消息 ``` -OpenIM.iMManager.messageManager.deleteMessageFromLocalStorage(message); +Message message = await OpenIM.iMManager.messageManager.createQuoteMessage( + text: '消息内容', + quoteMsg: '被引用的消息对象Message', +) ``` - 参数说明: -| 名称 | 类型 | 描述 | -| ------- | ------- | ---------------- | -| message | Message | 被删除的消息对象 | - - +| 名称 | 类型 | 描述 | +| -------- | ----------- | ----------------------- | +| text | String | 消息内容 | +| quoteMsg | Message对象 | 被引用的消息对象Message | -## 3.26. insertSingleMessageToLocalStorage +## 3.26 . createCardMessage -插入一条消息到本地。 +创建名片消息 ``` -OpenIM.iMManager.messageManager.insertSingleMessageToLocalStorage( userID: '接收者ID', message: '消息结构体', sender: '发送者ID') +Message message = await OpenIM.iMManager.messageManager.createCardMessage( + data: '用户信息Map', +) ``` - 参数说明: -| 名称 | 类型 | 描述 | -| -------- | ------- | ---------- | -| recevier | String | 接收者ID | -| sender | String | 发送者ID | -| message | Message | 消息结构体 | +| 名称 | 类型 | 描述 | +| ---- | ---- | ------------------------------------------------------------ | +| data | Map | 如{"uid": uid, 'name': name, 'icon': icon},按需求自定义内容。 | +## 3.27. clearC2CHistoryMessage +清空单聊记录 -## 3.27. findMessages +``` + OpenIM.iMManager.messageManager.clearC2CHistoryMessage(uid: 'uid'); +``` -根据消息ID查找本地消息。 +## 3.28. clearGroupHistoryMessage + +清空群聊记录 ``` -OpenIM.iMManager.messageManager.findMessages(messageIDList: [id1,di2]) + OpenIM.iMManager.messageManager.clearGroupHistoryMessage(gid: 'gid'); ``` -- 参数说明: -| 名称 | 类型 | 描述 | -| ------------- | ------------- | ------------------------- | -| messageIDList | List< String> | 消息id(clientMsgID)集合 | +# 4. 会话 +## 4.1. setConversationListener -# 4. 会话 +设置会话监听器,会话记录发生改变时回调。 +``` + OpenIM.iMManager.conversationManager.setConversationListener( + OnConversationListener( + onConversationChanged: (List list) {}, + onNewConversation: (List list) {}, + onSyncServerFailed: () {}, + onSyncServerFinish: () {}, + onSyncServerStart: () {}, + onTotalUnreadMessageCountChanged: (int count) {}, + ), + ); +``` +| 事件回调 | 事件描述 | 推荐操作 | +| -------------------------- | -------------------- | -------------- | +| conversationChanged | 会话记录发生改变 | 更新会话列表 | +| newConversation | 有新的会话被添加 | 更新会话列表 | +| totalUnreadMsgCountChanged | 未读消息总数发生改变 | 更新消息未读数 | -## 4.1. getAllConversationList +## 4.2. getAllConversationList 拉取当前所有的会话记录 @@ -713,14 +737,30 @@ OpenIM.iMManager.messageManager.findMessages(messageIDList: [id1,di2]) List list = await OpenIM.iMManager.conversationManager.getAllConversationList() ``` +## 4.3. getConversationListSplit + +分页获取会话列表 + +``` + OpenIM.iMManager.conversationManager.getConversationListSplit(offset: offest,count: count) +``` + +- 参数说明: +| 名称 | 类型 | 描述 | +| ------ | ---- | --------------------------------------------------- | +| offest | int | 偏移量,默认0。如第一次拉取20条,下一次的offset为20 | +| count | int | 当前拉取的数量 | -## 4.2. getOneConversation +## 4.4. getOneConversation -根据用户ID或群聊ID和session类型获取单个会话。 +根据用户ID或群聊ID和session类型获取单个会话。会话不存在的情况下会创建一个空会话 ``` -ConversationInfo info = await OpenIM.iMManager.conversationManager.getSingleConversation( sourceID: sourceID, sessionType: sessionType,) +ConversationInfo info = await OpenIM.iMManager.conversationManager.getSingleConversation( + sourceID: sourceID, + sessionType: sessionType, +) ``` - 参数说明: @@ -730,9 +770,7 @@ ConversationInfo info = await OpenIM.iMManager.conversationManager.getSingleConv | sourceID | String | 如果是单聊其值为单聊对象的userId;如果是群聊其值为群的groupId | | sessionType | String | 如果是单聊sessionType=1;群聊sessionType=2 | - - -## 4.3. getMultipleConversation +## 4.5. getMultipleConversation 根据会话ID获取多个会话。 @@ -746,14 +784,12 @@ List list = await OpenIM.iMManager.conversationManager.getMul | ------------------ | ------------- | ------------ | | conversationIDList | List< String> | 会话的id集合 | - - -## 4.4. deleteConversation +## 4.6. deleteConversation 删除会话,执行此操作会触发会话记录发生改变回调。 ``` -OpenIM.iMManager.conversationManager.deleteConversation( conversationID: conversationID,); +OpenIM.iMManager.conversationManager.deleteConversation(conversationID: conversationID,); ``` - 参数说明: @@ -762,14 +798,15 @@ OpenIM.iMManager.conversationManager.deleteConversation( conversationID: conver | -------------- | ------ | -------------- | | conversationID | String | 被删除的会话id | - - -## 4.5. setConversationDraft +## 4.7. setConversationDraft 设置草稿,执行此操作会触发会话记录发生改变回调。 ``` -OpenIM.iMManager.conversationManager.setConversationDraft( conversationID: conversationID, draftText: draftText,); +OpenIM.iMManager.conversationManager.setConversationDraft( + conversationID: conversationID, + draftText: draftText, +); ``` - 参数说明: @@ -779,14 +816,12 @@ OpenIM.iMManager.conversationManager.setConversationDraft( conversationID: conv | draftText | String | 未完成发送的消息内容 | | conversationID | String | 会话id | - - -## 4.6. pinConversation +## 4.8. pinConversation 置顶会话,执行此操作会触发会话记录发生改变回调。 ``` -OpenIM.iMManager.conversationManager.pinConversation( conversationID: conversationID, isPinned: true,); +OpenIM.iMManager.conversationManager.pinConversation(conversationID: conversationID, isPinned: true,); ``` - 参数说明: @@ -798,9 +833,7 @@ OpenIM.iMManager.conversationManager.pinConversation( conversationID: conversat 注:ConversationInfo对象里的isPinned字段,isPinned==1代表置顶 - - -## 4.7. markSingleMessageHasRead +## 4.9. markSingleMessageHasRead 标记单聊会话消息为已读。 @@ -814,9 +847,7 @@ OpenIM.iMManager.conversationManager.markSingleMessageHasRead(userID: userID) | ------ | ------ | ---------- | | userID | String | 单聊用户id | - - -## 4.8. markGroupMessageHasRead +## 4.10. markGroupMessageHasRead 标记群聊会话消息已读。 @@ -830,9 +861,7 @@ OpenIM.iMManager.conversationManager.markGroupMessageHasRead(groupID: groupID) | ------- | ------ | ------ | | groupID | String | 群组id | - - -## 4.9. getTotalUnreadMsgCount +## 4.11. getTotalUnreadMsgCount 获取消息总未读。 @@ -840,41 +869,91 @@ OpenIM.iMManager.conversationManager.markGroupMessageHasRead(groupID: groupID) int count = await OpenIM.iMManager.conversationManager.getTotalUnreadMsgCount(); ``` +## 4.12. getConversationID - -## 4.10. setConversationListener - -设置会话监听器,会话记录发生改变时回调。 +获取会话ID ``` -OpenIM.iMManager.conversationManager.setConversationListener(OnConversationListener( conversationChanged: (list){ // 会话记录改变 }, newConversation: (list){ // 新增会话 }, totalUnreadMsgCountChanged: (count){ // 未读消息总数改变 }, syncServerFailed: () {}, syncServerFinish: () {}, syncServerStart: () {},)); +OpenIM.iMManager.conversationManager.getConversationID( + sourceID: sourceID, + sessionType: sessionType +) ``` -| 事件回调 | 事件描述 | 推荐操作 | -| -------------------------- | -------------------- | -------------- | -| conversationChanged | 会话记录发生改变 | 刷新会话列表 | -| newConversation | 有新的会话被添加 | 刷新会话列表 | -| totalUnreadMsgCountChanged | 未读消息总数发生改变 | 刷新消息未读数 | - - +- 参数说明: -# 5.好友关系 +| 名称 | 类型 | 描述 | +| ----------- | ------ | ------------------------------------------------------------ | +| sourceID | String | 如果是单聊其值为单聊对象的userId;如果是群聊其值为群的groupId | +| sessionType | String | 如果是单聊sessionType=1;群聊sessionType=2 | -## 5.1. getFriendList +## 4.13. setConversationRecvMessageOpt -获取好友列表。 +设置会话消息免打扰 ``` -List list = await OpenIM.iMManager.friendshipManager.getFriendList(); +OpenIM.iMManager.conversationManager.conversationIDList( + conversationIDList: conversationIDList, + status: status +) ``` -如果需要做联系人A-Z列表效果,推荐使用方法getFriendListMap, 该方法返回值为Future> ,然后再将list转换为你自己的List Object,如: +- 参数说明: + +| 名称 | 类型 | 描述 | +| ------------------ | ------------ | --------------------------------------------------- | +| conversationIDList | List | 会话id列表 | +| status | int | 1:不接受消息和推送;2:接受消息但没有推送;0:正常 | + +## 4.14. getConversationRecvMessageOpt + +获取会话消息免打扰状态 ``` -OpenIM.iMManager.friendshipManager.getFriendListMap() .then((list) => list.map((e) => ContactsInfo.fromJson(e)).toList()); +OpenIM.iMManager.conversationManager.getConversationRecvMessageOpt( + conversationIDList: conversationIDList, +) ``` +- 参数说明: + +| 名称 | 类型 | 描述 | +| ------------------ | ------------ | ---------- | +| conversationIDList | List | 会话id列表 | + + + +# 5.好友关系 + +## 5.1. setFriendListener + +设置好友监听器。 +``` + OpenIM.iMManager.friendshipManager.setFriendshipListener(OnFriendshipListener( + onBlackListAdd: (UserInfo u) {}, + onBlackListDeleted: (UserInfo u) {}, + onFriendApplicationListAccept: (UserInfo u) {}, + onFriendApplicationListAdded: (UserInfo u) {}, + onFriendApplicationListDeleted: (UserInfo u) {}, + onFriendApplicationListReject: (UserInfo u) {}, + onFriendInfoChanged: (UserInfo u) {}, + onFriendListAdded: (UserInfo u) {}, + onFriendListDeleted: (UserInfo u) {}, + )); +``` + +| 事件回调 | 事件描述 | 推荐操作 | +| ---------------------------- | ---------------------- | ---------------------------------- | +| blackListAdd | 好友被加入黑名 | 刷新好友列表或黑名单列表 | +| blackListDeleted | 好友从黑名单移除 | 刷新好友列表或黑名单列表 | +| friendApplicationListAccept | 发起的好友请求被接受 | 刷新好友请求列表 | +| friendApplicationListAdded | 别人向我发起了好友请求 | 刷新好友请求列表 | +| friendApplicationListDeleted | 好友申请被删除 | 刷新好友请求列表 | +| friendApplicationListReject | 请求被拒绝 | 刷新好友请求列表 | +| friendInfoChanged | 好友资料发生变化 | 刷新好友列表,好友信息或黑名单列表 | +| friendListAdded | 已成为好友 | 刷新好友列表 | +| friendListDeleted | 好友被删除 | 刷新好友列表 | ## 5.2. getFriendsInfo @@ -890,9 +969,32 @@ List list = await OpenIM.iMManager.friendshipManager.getFriendsInfo(ui | ------- | ------------- | ------------ | | uidList | List< String> | 用户的ID集合 | +## 5.3. addFriend + +发起添加好友申请。 + +``` +OpenIM.iMManager.friendshipManager.addFriend(uid: uid, reason: reason); +``` + +- 参数说明: + +| 名称 | 类型 | 描述 | +| ------ | ------ | -------- | +| uid | String | 用户的ID | +| reason | String | 添加说明 | + +返回Future,执行then方法为添加成功,执行cathError方法为添加失败。 +## 5.4. getFriendList + +获取好友列表。返回的数据包含了黑名单。 + +``` +List list = await OpenIM.iMManager.friendshipManager.getFriendList(); +``` -## 5.3. setFriendInfo +## 5.5. setFriendInfo 设置好友备注信息。 @@ -907,9 +1009,7 @@ OpenIM.iMManager.friendshipManager.setFriendInfo(uid: uid, comment: '备注') | uid | String | 用户的ID | | comment | String | 备注 | - - -## 5.4. checkFriend +## 5.6. checkFriend 检查与用户间是否有好友关系。 @@ -925,9 +1025,7 @@ List list = await OpenIM.iMManager.friendshipManager.checkFriend([id1, 根据类UserInfo的flag字段判断。flag == 1:是好友关系,其他非好友关系。 - - -## 5.5. deleteFromFriendList +## 5.7. deleteFromFriendList 从好友列表中删除用户。 @@ -943,28 +1041,7 @@ OpenIM.iMManager.friendshipManager.deleteFromFriendList(uid: uid); 返回Future,执行then方法为删除成功,执行cathError方法为删除失败。 - - -## 5.6. addFriend - -发起添加好友申请。 - -``` -OpenIM.iMManager.friendshipManager.addFriend(uid: uid, reason: reason); -``` - -- 参数说明: - -| 名称 | 类型 | 描述 | -| ------ | ------ | -------- | -| uid | String | 用户的ID | -| reason | String | 添加说明 | - -返回Future,执行then方法为添加成功,执行cathError方法为添加失败。 - - - -## 5.7. getFriendApplicationList +## 5.8. getFriendApplicationList 获取好友请求列表。 @@ -976,9 +1053,7 @@ List list = await OpenIM.iMManager.friendshipManager.getFriendApplicat 注:新朋友的红点数通过计算列表里flag == 0的item的数量。 - - -## 5.8. acceptFriendApplication +## 5.9. acceptFriendApplication 接受好友请求。 @@ -990,9 +1065,7 @@ uid:为好友申请列表返回的数据里UserInfo类的uid字段。 返回Future,执行then方法为操作成功,执行cathError方法为操作失败。 - - -## 5.9. refuseFriendApplication +## 5.10. refuseFriendApplication 拒绝好友请求。 @@ -1002,9 +1075,7 @@ OpenIM.iMManager.friendshipManager.refuseFriendApplication(uid: uid) 返回Future,执行then方法为操作成功,执行cathError方法为操作失败。 - - -## 5.10. addToBlackList +## 5.11. addToBlackList 将用户添加到黑名单。 @@ -1014,9 +1085,7 @@ OpenIM.iMManager.friendshipManager.addToBlackList(uid: uid) 返回Future,执行then方法为操作成功,执行cathError方法为操作失败。 - - -## 5.11. deleteFromBlackList +## 5.12. deleteFromBlackList 从黑名单移除用户。 @@ -1026,9 +1095,7 @@ OpenIM.iMManager.friendshipManager.deleteFromBlackList(uid: uid); 返回Future,执行then方法为操作成功,执行cathError方法为操作失败。 - - -## 5.12. getBlackList +## 5.13. getBlackList 获取黑名单列表。 @@ -1040,38 +1107,20 @@ List list = await OpenIM.iMManager.friendshipManager.getBlackList(); -## 5.13. setFriendListener - -设置好友监听器。 - -``` -OpenIM.iMManager.friendshipManager.setFriendshipListener(OnFriendshipListener( blackListAdd: (u){ // 好友被加入黑名时单回调 }, blackListDeleted: (u){ // 好友从黑名单移除时回调 }, friendApplicationListAccept: (u){ // 发起的好友请求被接受时回调 }, friendApplicationListAdded: (u){ // 我接受被人的发起的好友请求时回调 }, friendApplicationListDeleted: (u){ // 删除好友请求时回调 }, friendApplicationListReject: (u){ // 请求被拒绝回调 }, friendInfoChanged: (u){ // 好友资料发生变化时回调 }, friendListAdded: (u){ // 已添加好友回调 }, friendListDeleted: (u){ // 好友被删除时回调 },)); -``` - -| 事件回调 | 事件描述 | 推荐操作 | -| ---------------------------- | -------------------------- | ---------------------------------- | -| blackListAdd | 好友被加入黑名 | 刷新好友列表或黑名单列表 | -| blackListDeleted | 好友从黑名单移除 | 刷新好友列表或黑名单列表 | -| friendApplicationListAccept | 发起的好友请求被接受 | 刷新好友请求列表 | -| friendApplicationListAdded | 别人向我发起了好友请求 | 刷新好友请求列表 | -| friendApplicationListDeleted | 删除好友请求 | 刷新好友请求列表 | -| friendApplicationListReject | 请求被拒绝 | 刷新好友请求列表 | -| friendInfoChanged | 好友资料发生变化 | 刷新好友列表,好友信息或黑名单列表 | -| friendListAdded | 已成为好友 | 刷新好友列表 | -| friendListDeleted | 好友被删除 | 刷新好友列表 | - - - # 6. 群关系 - - ## 6.1. createGroup 创建一个群聊,并指定群信息以及群成员。 ``` -OpenIM.iMManager.groupManager.createGroup( groupName: groupName, notification: notification, introduction: introduction, faceUrl: faceUrl, list: roles,) +OpenIM.iMManager.groupManager.createGroup( + groupName: groupName, + notification: notification, + introduction: introduction, + faceUrl: faceUrl, + list: roles, +) ``` - 参数说明: @@ -1084,8 +1133,6 @@ OpenIM.iMManager.groupManager.createGroup( groupName: groupName, notification: | faceUrl | String | 群icon | | list | List< GroupMemberRole> | 在发起群聊时选择的群成员列表。
GroupMemberRole类字段说明:setRole:0:普通成员 2:管理员;uid:成员的uid。 | - - ## 6.2. getGroupsInfo 批量获取群组信息。 @@ -1100,20 +1147,22 @@ List list = await OpenIM.iMManager.groupManager.getGroupsInfo(gidList | ------- | ------------- | ---------- | | gidList | List< String> | 群组id集合 | - - ## 6.3. setGroupInfo 设置、更新群聊信息。 ``` -OpenIM.iMManager.groupManager.setGroupInfo( groupName: groupName, notification: notification, introduction: introduction, faceUrl: faceUrl, ) +OpenIM.iMManager.groupManager.setGroupInfo( + groupID: groupID, + groupName: groupName, + notification: notification, + introduction: introduction, + faceUrl: faceUrl, +) ``` 返回Future,执行then方法为操作成功,执行cathError方法为操作失败。 - - ## 6.4. getJoinedGroupList 获取已加入的群列表。 @@ -1124,8 +1173,6 @@ List list = await OpenIM.iMManager.groupManager.getJoinedGroupList(); 如果类GroupInfo的ownerId字段的值跟当前用户的uid一致,则当前用户就是群的发起者。否则是参与者。 - - ## 6.5. getGroupMemberList 获取群成员列表。 @@ -1133,7 +1180,11 @@ List list = await OpenIM.iMManager.groupManager.getJoinedGroupList(); GroupMembersList类的nextSeq字段:下一页的开始index。data字段:群成员。 ``` -GroupMembersList value = await OpenIM.iMManager.groupManager.getGroupMemberList( groupId: gid, filter:0, next:0,) +GroupMembersList value = await OpenIM.iMManager.groupManager.getGroupMemberList( + groupId: gid, + filter:0, + next:0, +) ``` - 参数说明: @@ -1144,14 +1195,15 @@ GroupMembersList value = await OpenIM.iMManager.groupManager.getGroupMemberList( | filter | int | 过滤成员,0不过滤,1群的创建者,2管理员;默认值0 | | next | int | 分页,从哪一条开始获取,默认值0。参照GroupMembersList的nextSeq字段的值。 | - - ## 6.6. getGroupMembersInfo 批量获取群成员信息。 ``` -List list = await OpenIM.iMManager.groupManager.getGroupMembersInfo( groupId: groupId, uidList: uidList) +List list = await OpenIM.iMManager.groupManager.getGroupMembersInfo( + groupId: groupId, + uidList: uidList +) ``` - 参数说明: @@ -1161,8 +1213,6 @@ List list = await OpenIM.iMManager.groupManager.getGroupMember | groupId | String | 群组id | | uidList | List< String> | 群成员ID集合 | - - ## 6.7. joinGroup 申请加入群聊。 @@ -1180,8 +1230,6 @@ OpenIM.iMManager.groupManager.joinGroup(gid: gid, reason: null) 返回Future,执行then方法为操作成功,执行cathError方法为操作失败。 - - ## 6.8. getGroupApplicationList 获取加入群聊申请列表。 @@ -1197,8 +1245,6 @@ GroupApplicationList list = await OpenIM.iMManager.groupManager.getGroupApplicat | count | int | 未处理数 | | user | List< GroupApplicationInfo> | 申请列表 | - - ## 6.9. acceptGroupApplication 同意入群请求。 @@ -1216,8 +1262,6 @@ OpenIM.iMManager.groupManager.acceptGroupApplication(info: info, reason: reason) 返回Future,执行then方法为操作成功,执行cathError方法为操作失败。 - - ## 6.10. refuseGroupApplication 拒绝入群请求。 @@ -1235,14 +1279,16 @@ OpenIM.iMManager.groupManager.refuseGroupApplication(info: info, reason: reason) 返回Future,执行then方法为操作成功,执行cathError方法为操作失败。 - - ## 6.11. inviteUserToGroup 邀请用户加入群组(可批量)。 ``` -OpenIM.iMManager.groupManager.inviteUserToGroup( groupId: gid, uidList: uidList, reason: reason,); +OpenIM.iMManager.groupManager.inviteUserToGroup( + groupId: gid, + uidList: uidList, + reason: reason, +); ``` - 参数说明: @@ -1255,14 +1301,16 @@ OpenIM.iMManager.groupManager.inviteUserToGroup( groupId: gid, uidList: uidLis 返回Future,执行then方法为操作成功,执行cathError方法为操作失败。 - - ## 6.12. kickGroupMember 踢出群聊(可批量)。 ``` -OpenIM.iMManager.groupManager.kickGroupMember( groupId: gid, uidList: uidList, reason: reason,); +OpenIM.iMManager.groupManager.kickGroupMember( + groupId: gid, + uidList: uidList, + reason: reason, +); ``` - 参数说明: @@ -1275,8 +1323,6 @@ OpenIM.iMManager.groupManager.kickGroupMember( groupId: gid, uidList: uidList, 返回Future,执行then方法为操作成功,执行cathError方法为操作失败。 - - ## 6.13. quitGroup 退出群聊。 @@ -1287,8 +1333,6 @@ OpenIM.iMManager.groupManager.quitGroup(gid: gid) 返回Future,执行then方法为操作成功,执行cathError方法为操作失败。 - - ## 6.14. transferGroupOwner 转让群主。 @@ -1306,14 +1350,21 @@ OpenIM.iMManager.groupManager.transferGroupOwner(gid: gid, uid: uid) 注:此方法只有群的发起者(拥有者)才有权限访问,管理员和普通成员无权限访问。如果是发起者群资料展示可显示群权限转移按钮。 - - ## 6.15. setGroupListener 设置群组监听器。 ``` -OpenIM.iMManager.groupManager.setGroupListener(OnGroupListener( applicationProcessed: (groupId, opUser, agreeOrReject, opReason){ // 群申请被处理时回调 }, groupCreated: (groupId){ // 群创建完成时回调 }, groupInfoChanged: (groupId, info){ // 群资料发生变化时回调 }, memberEnter: ( groupId, list){ // 有人进群时回调 }, memberInvited: ( groupId, opUser, list){ // 接受邀请时回调 }, memberKicked: ( groupId, opUser, list){ // 成员被踢出时回调 }, memberLeave: ( groupId, info){ // 群成员退群时回调 }, receiveJoinApplication: ( groupId, info, opReason){ // 收到入群申请 },)) + OpenIM.iMManager.groupManager.setGroupListener(OnGroupListener( + onApplicationProcessed: (groupId, opUser, agreeOrReject, opReason) {}, + onGroupCreated: (groupId) {}, + onGroupInfoChanged: (groupId, info) {}, + onMemberEnter: (groupId, list) {}, + onMemberInvited: (groupId, opUser, list) {}, + onMemberKicked: (groupId, opUser, list) {}, + onMemberLeave: (groupId, info) {}, + onReceiveJoinApplication: (groupId, info, opReason) {}, + )); ``` | 事件回调 | 事件描述 | 推荐操作 | @@ -1327,14 +1378,28 @@ OpenIM.iMManager.groupManager.setGroupListener(OnGroupListener( applicationProc | memberLeave | 群成员退群 | 刷新群成员列表 | | receiveJoinApplication | 收到入群申请 | | -### + # 7. 数据对象结构 ## 7.1. 用户信息对象 ``` -class UserInfo { String uid; String? name; String? icon; int? gender; String? mobile; String? birth; String? email; String? ex; String? comment; int? isInBlackList; String? reqMessage; String? applyTime; int? flag; } +class UserInfo { + String uid; + String? name; + String? icon; + int? gender; + String? mobile; + String? birth; + String? email; + String? ex; + String? comment; + int? isInBlackList; + String? reqMessage; + String? applyTime; + int? flag; +} ``` | Field | **Description** | @@ -1351,20 +1416,50 @@ class UserInfo { String uid; String? name; String? icon; int? gender; Strin | isInBlackList | 黑名单:1已拉入黑名单 | | reqMessage | 验证消息 | | applyTime | 申请时间 | -| flag | 好友申请列表:0等待处理;1已同意;2已拒绝
好友关系:1已经是好友 | - - +| flag | 好友申请列表:0等待处理;1已同意;-1已拒绝
好友关系:1已经是好友 | ## 7.2. 消息对象 ``` -class Message { String? clientMsgID; String? serverMsgID; int? createTime; int? sendTime; String? sendID; String? recvID; int? msgFrom; /// [MessageType] int? contentType; int? platformID; List? forceList; String? senderNickName; String? senderFaceUrl; String? groupID; String? content; int? seq; bool? isRead; /// [MessageStatus] int? status; String? remark; dynamic ext; /// [ConversationType] int? sessionType; PictureElem? pictureElem; SoundElem? soundElem; VideoElem? videoElem; FileElem? fileElem; AtElem? atElem; LocationElem? locationElem; CustomElem? customElem; QuoteElem? quoteElem; MergeElem? mergeElem;}class PictureElem { String? sourcePath; PictureInfo? sourcePicture; PictureInfo? bigPicture; PictureInfo? snapshotPicture;}class PictureInfo { String? uuID; String? type; int? size; int? width; int? height; String? url;}class SoundElem { String? uuID; String? soundPath; String? sourceUrl; int? dataSize; int? duration;}class VideoElem { String? videoPath; String? videoUUID; String? videoUrl; String? videoType; int? videoSize; int? duration; String? snapshotPath; String? snapshotUUID; int? snapshotSize; String? snapshotUrl; int? snapshotWidth; int? snapshotHeight;}class FileElem { String? filePath; String? uuID; String? sourceUrl; String? fileName; int? fileSize;}class AtElem { String? text; List? atUserList; bool? isAtSelf;}class LocationElem { String? description; double? longitude; double? latitude;}class CustomElem { Uint8List? data; Uint8List? extension; String? description;}class QuoteElem { String? text; Message? quoteMessage;}class MergeElem { String? title; List? abstractList; List? multiMessage;} +class Message { + String? clientMsgID; + String? serverMsgID; + int? createTime; + int? sendTime; + String? sendID; + String? recvID; + int? msgFrom; + + /// [MessageType] + int? contentType; + int? platformID; + List? forceList; + String? senderNickName; + String? senderFaceUrl; + String? groupID; + String? content; + int? seq; + bool? isRead; + + /// [MessageStatus] + int? status; + String? remark; + dynamic ext; + + /// [ConversationType] + int? sessionType; + PictureElem? pictureElem; + SoundElem? soundElem; + VideoElem? videoElem; + FileElem? fileElem; + AtElem? atElem; + LocationElem? locationElem; + CustomElem? customElem; + QuoteElem? quoteElem; + MergeElem? mergeElem; +} ``` - - -### 7.2.1. Message - | Field | Description | | -------------- | ------------------------------------------------------------ | | clientMsgID | 消息唯一ID | @@ -1374,8 +1469,8 @@ class Message { String? clientMsgID; String? serverMsgID; int? createTime; i | sendID | 发送者ID | | recvID | 接收者ID | | msgFrom | 标识消息是用户级别还是系统级别 100:用户 200:系统 | -| contentType | 消息类型:
101:文本消息
102:图片消息
103:语音消息
104:视频消息
105:文件消息
106:@消息
107:合并消息
108:转发消息
109:位置消息
110:自定义消息
111:撤回消息回执
112:C2C已读回执
113:正在输入状态 | -| platformID | 平台类型 1:ios 2:android 3:windows 4:osx 5:web 6:mini 7:linux | +| contentType | 消息类型:
101:文本消息
102:图片消息
103:语音消息
104:视频消息
105:文件消息
106:@消息
107:合并消息
108:名片消息
109:位置消息
110:自定义消息
111:撤回消息回执
112:C2C已读回执
113:正在输入状态
114:引用消息
| +| platformID | 平台类型
1:ios
2:android
3:windows
4:osx
5:web
6:mini
7:linux | | forceList | 强制推送列表(被@的用户) | | senderNickName | 发送者昵称 | | senderFaceUrl | 发送者头像 | @@ -1383,7 +1478,7 @@ class Message { String? clientMsgID; String? serverMsgID; int? createTime; i | content | 消息内容 | | seq | 消息唯一序列号 | | isRead | 是否已读 | -| status | 消息状态 1:发送中 2:发送成功 3:发送失败 4:已删除 5:已撤回 | +| status | 消息状态
1:发送中
2:发送成功
3:发送失败
4:已删除
5:已撤回 | | remark | 消息备注 | | sessionType | 会话类型 1:单聊 2:群聊 | | pictureElem | 图片信息 | @@ -1396,9 +1491,7 @@ class Message { String? clientMsgID; String? serverMsgID; int? createTime; i | quoteElem | 引用消息 | | mergeElem | 合并信息 | - - -### 7.2.2. PictureElem +### 7.2.1. PictureElem | Field | Description | | --------------- | ------------ | @@ -1407,9 +1500,7 @@ class Message { String? clientMsgID; String? serverMsgID; int? createTime; i | bigPicture | 大图详情 | | snapshotPicture | 缩略图详情 | - - -### 7.2.3. PictureInfo +### 7.2.2. PictureInfo | Field | Description | | ------ | ----------- | @@ -1420,9 +1511,7 @@ class Message { String? clientMsgID; String? serverMsgID; int? createTime; i | height | 图片高度 | | url | 图片oss地址 | - - -### 7.2.4. SoundElem +### 7.2.3. SoundElem | Field | Description | | --------- | ------------ | @@ -1432,9 +1521,7 @@ class Message { String? clientMsgID; String? serverMsgID; int? createTime; i | dataSize | 音频大小 | | duration | 音频时长 | - - -### 7.2.5. VideoElem +### 7.2.4. VideoElem | Field | Description | | -------------- | ---------------- | @@ -1451,9 +1538,7 @@ class Message { String? clientMsgID; String? serverMsgID; int? createTime; i | snapshotWidth | 视频快照宽度 | | snapshotHeight | 视频快照高度 | - - -### 7.2.6. FileElem +### 7.2.5. FileElem | Field | Description | | --------- | ---------------- | @@ -1463,9 +1548,7 @@ class Message { String? clientMsgID; String? serverMsgID; int? createTime; i | fileName | 文件名称 | | fileSize | 文件大小 | - - -### 7.2.7. MergeElem +### 7.2.6. MergeElem | Field | Description | | ------------ | ------------ | @@ -1473,9 +1556,7 @@ class Message { String? clientMsgID; String? serverMsgID; int? createTime; i | abstractList | 摘要列表 | | multiMessage | 合并消息列表 | - - -### 7.2.8. AtElem +### 7.2.7. AtElem | Field | Description | | ---------- | ----------- | @@ -1483,9 +1564,7 @@ class Message { String? clientMsgID; String? serverMsgID; int? createTime; i | atUserList | @用户ID列表 | | isAtSelf | 是否@自己 | - - -### 7.2.9. LocationElem +### 7.2.8. LocationElem | Field | Description | | ----------- | ----------- | @@ -1493,9 +1572,7 @@ class Message { String? clientMsgID; String? serverMsgID; int? createTime; i | longitude | 经度 | | latitude | 纬度 | - - -### 7.2.10. CustomElem +### 7.2.9. CustomElem | Field | Description | | ----------- | ---------------------- | @@ -1503,20 +1580,34 @@ class Message { String? clientMsgID; String? serverMsgID; int? createTime; i | extension | 自定义消息扩展字节数据 | | description | 描述 | - - -### 7.2.11. QuoteElem +### 7.2.10. QuoteElem | Field | Description | | ------------ | ----------- | | quoteMessage | 引用消息 | - - ## 7.3. 会话对象 ``` -class ConversationInfo { String conversationID; /// [ConversationType] int? conversationType; String? userID; String? groupID; String? showName; String? faceUrl; int? recvMsgOpt; int? unreadCount; Message? latestMsg; int? latestMsgSendTime; String? draftText; int? draftTimestamp; /// pinned value is 1 dynamic isPinned; } +class ConversationInfo { + String conversationID; + + /// [ConversationType] + int? conversationType; + String? userID; + String? groupID; + String? showName; + String? faceUrl; + int? recvMsgOpt; + int? unreadCount; + Message? latestMsg; + int? latestMsgSendTime; + String? draftText; + int? draftTimestamp; + + /// pinned value is 1 + dynamic isPinned; +} ``` | Field | Description | @@ -1527,37 +1618,49 @@ class ConversationInfo { String conversationID; /// [ConversationType] int? c | groupID | 会话群聊ID | | showName | 会话对象(用户或群聊)名称 | | faceUrl | 用户头像或群聊头像 | -| recvMsgOpt | 接收消息选项:
1:在线正常接收消息,离线时进行推送
2:不会接收到消息
3:在线正常接收消息,离线不会有推送 | +| recvMsgOpt | 接收消息选项:
0:在线正常接收消息,离线时进行推送
1:不会接收到消息
2:在线正常接收消息,离线不会有推送 | | unreadCount | 未读消息数量 | -| latestMsg | 最后一条消息 [消息对象](http://1.14.194.38:13123/client_doc/uni_doc.html)json字符串 | +| latestMsg | 最后一条消息json字符串 | | latestMsgSendTime | 最后一条消息发送时间(ns) | | draftText | 会话草稿 | | draftTimestamp | 会话草稿设置时间 | | isPinned | 是否置顶,1置顶 | - - ## 7.4. 已读消息回执 ``` -class HaveReadInfo { String? uid; List? msgIDList; int? readTime; int? msgFrom; int? contentType; int? sessionType; } +class HaveReadInfo { + String? uid; + List? msgIDList; + int? readTime; + int? msgFrom; + int? contentType; + int? sessionType; +} ``` | Field | Description | | ----------- | ------------------------------------------------------------ | | uid | 单聊对象的ID | -| contentType | 消息类型: 101:文本消息 102:图片消息 103:语音消息 104:视频消息 105:文件消息 106:@消息 107:合并消息 108:转发消息 109:位置消息 110:自定义消息 111:撤回消息回执 112:C2C已读回执 113:正在输入状态 | +| contentType | 消息类型:
101:文本消息
102:图片消息
103:语音消息
104:视频消息
105:文件消息
106:@消息
107:合并消息
108:名片消息
109:位置消息
110:自定义消息
111:撤回消息回执
112:C2C已读回执
113:正在输入状态
114:引用消息
| | msgFrom | 标识消息是用户级别还是系统级别 100:用户 200:系统 | | msgIDList | 已读消息clientMsgID集合 | | readTime | 已读时间 | | sessionType | 会话类型 1:单聊 2:群聊 | - - ## 7.5. 群组信息对象 ``` -class GroupInfo { String groupID; String? groupName; String? notification; String? introduction; String? faceUrl; String? ownerId; int? createTime; int? memberCount; } +class GroupInfo { + String groupID; + String? groupName; + String? notification; + String? introduction; + String? faceUrl; + String? ownerId; + int? createTime; + int? memberCount; +} ``` | Field | Description | @@ -1571,12 +1674,18 @@ class GroupInfo { String groupID; String? groupName; String? notification; S | createTime | 群组创建时间 | | memberCount | 群成员总数 | - - ## 7.6. 群组成员信息 ``` -class GroupMembersInfo { String? groupID; String? userId; int? role; int? joinTime; String? nickName; String? faceUrl; dynamic ext; } +class GroupMembersInfo { + String? groupID; + String? userId; + int? role; + int? joinTime; + String? nickName; + String? faceUrl; + dynamic ext; +} ``` | Field | Description | @@ -1589,12 +1698,27 @@ class GroupMembersInfo { String? groupID; String? userId; int? role; int? jo | faceUrl | 头像 | | ext | 扩展字段 | - - ## 7.7. 群申请信息 ``` -class GroupApplicationInfo { String? id; String? groupID; String? fromUserID; String? toUserID; int? flag; //INIT = 0, REFUSE = -1, AGREE = 1 String? reqMsg; String? handledMsg; int? createTime; String? fromUserNickName; String? toUserNickName; String? fromUserFaceURL; String? toUserFaceURL; String? handledUser; int? type; //APPLICATION = 0, INVITE = 1 int? handleStatus; //UNHANDLED = 0, BY_OTHER = 1, BY_SELF = 2 int? handleResult; //REFUSE = 0, AGREE = 1 } +class GroupApplicationInfo { + String? id; + String? groupID; + String? fromUserID; + String? toUserID; + int? flag; //INIT = 0, REFUSE = -1, AGREE = 1 + String? reqMsg; + String? handledMsg; + int? createTime; + String? fromUserNickName; + String? toUserNickName; + String? fromUserFaceURL; + String? toUserFaceURL; + String? handledUser; + int? type; //APPLICATION = 0, INVITE = 1 + int? handleStatus; //UNHANDLED = 0, BY_OTHER = 1, BY_SELF = 2 + int? handleResult; //REFUSE = 0, AGREE = 1 +} ``` | Field | Description | diff --git a/android/build.gradle b/android/build.gradle index 5b46479..1683426 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -51,5 +51,5 @@ android { } } dependencies { - implementation 'io.openim:client-sdk:1.4.4@aar' + implementation 'io.openim:client-sdk:1.4.5@aar' } \ No newline at end of file diff --git a/lib/src/manager/im_manager.dart b/lib/src/manager/im_manager.dart index 9861671..80527ae 100644 --- a/lib/src/manager/im_manager.dart +++ b/lib/src/manager/im_manager.dart @@ -336,8 +336,7 @@ class IMManager { /// Modify current user info Future setSelfInfo( - {required String uid, - String? name, + {String? name, String? icon, int? gender, String? mobile,