feat: add 'hideAllConversations', 'updateFcmToken'
This commit is contained in:
parent
2cafa6bab8
commit
cd506801cf
@ -193,4 +193,11 @@ public class ConversationManager extends BaseManager {
|
||||
int2long(methodCall, "duration")
|
||||
);
|
||||
}
|
||||
|
||||
public void hideAllConversations(MethodCall methodCall, MethodChannel.Result result) {
|
||||
Open_im_sdk.hideAllConversations(
|
||||
new OnBaseListener(result, methodCall),
|
||||
value(methodCall, "operationID")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,8 @@ public class IMManager extends BaseManager {
|
||||
Open_im_sdk.updateFcmToken(
|
||||
new OnBaseListener(result, methodCall),
|
||||
value(methodCall, "operationID"),
|
||||
value(methodCall, "fcmToken")
|
||||
value(methodCall, "fcmToken"),
|
||||
value(methodCall, "expireTime")
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ public class ConversationManager: BaseServiceManager {
|
||||
self["getAtAllTag"] = getAtAllTag
|
||||
self["setGlobalRecvMessageOpt"] = setGlobalRecvMessageOpt
|
||||
self["setConversationBurnDuration"] = setConversationBurnDuration
|
||||
self["hideAllConversations"] = hideAllConversations
|
||||
}
|
||||
|
||||
func setConversationListener(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
@ -113,6 +114,10 @@ public class ConversationManager: BaseServiceManager {
|
||||
func setConversationBurnDuration(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
Open_im_sdkSetConversationBurnDuration(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "conversationID"], methodCall[int32: "burnDuration"])
|
||||
}
|
||||
|
||||
func hideAllConversations(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
Open_im_sdkHideAllConversations(BaseCallback(result: result), methodCall[string: "operationID"])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -85,7 +85,8 @@ public class IMMananger: BaseServiceManager {
|
||||
}
|
||||
|
||||
func updateFcmToken(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||
Open_im_sdkUpdateFcmToken(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "fcmToken"])
|
||||
Open_im_sdkUpdateFcmToken(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "fcmToken"], methodCall[int64:
|
||||
"expireTime"])
|
||||
}
|
||||
|
||||
func setAppBackgroundStatus(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||
|
@ -16,16 +16,13 @@ class ConversationManager {
|
||||
}
|
||||
|
||||
/// Get All Conversations
|
||||
Future<List<ConversationInfo>> getAllConversationList(
|
||||
{String? operationID}) =>
|
||||
_channel
|
||||
Future<List<ConversationInfo>> getAllConversationList({String? operationID}) => _channel
|
||||
.invokeMethod(
|
||||
'getAllConversationList',
|
||||
_buildParam({
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) =>
|
||||
Utils.toList(value, (map) => ConversationInfo.fromJson(map)));
|
||||
.then((value) => Utils.toList(value, (map) => ConversationInfo.fromJson(map)));
|
||||
|
||||
/// Paginate Through Conversations
|
||||
/// [offset] Starting index
|
||||
@ -43,8 +40,7 @@ class ConversationManager {
|
||||
'count': count,
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) =>
|
||||
Utils.toList(value, (map) => ConversationInfo.fromJson(map)));
|
||||
.then((value) => Utils.toList(value, (map) => ConversationInfo.fromJson(map)));
|
||||
|
||||
/// Query a Conversation; if it doesn't exist, it will be created
|
||||
/// [sourceID] UserID for one-on-one conversation, GroupID for group conversation
|
||||
@ -62,8 +58,7 @@ class ConversationManager {
|
||||
"sessionType": sessionType,
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) =>
|
||||
Utils.toObj(value, (map) => ConversationInfo.fromJson(map)));
|
||||
.then((value) => Utils.toObj(value, (map) => ConversationInfo.fromJson(map)));
|
||||
|
||||
/// Get Multiple Conversations by Conversation ID
|
||||
/// [conversationIDList] List of conversation IDs
|
||||
@ -78,8 +73,7 @@ class ConversationManager {
|
||||
"conversationIDList": conversationIDList,
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) =>
|
||||
Utils.toList(value, (map) => ConversationInfo.fromJson(map)));
|
||||
.then((value) => Utils.toList(value, (map) => ConversationInfo.fromJson(map)));
|
||||
|
||||
/// Set Conversation Draft
|
||||
/// [conversationID] Conversation ID
|
||||
@ -126,26 +120,25 @@ class ConversationManager {
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Get Total Unread Message Count
|
||||
Future<dynamic> getTotalUnreadMsgCount({String? operationID}) =>
|
||||
/// Hide All Conversations
|
||||
Future hideAllConversations({
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'getTotalUnreadMsgCount',
|
||||
'hideAllConversations',
|
||||
_buildParam({
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Query Conversation ID
|
||||
/// [sourceID] UserID for one-on-one, GroupID for group
|
||||
/// [sessionType] Reference [ConversationType]
|
||||
Future<dynamic> getConversationIDBySessionType({
|
||||
required String sourceID,
|
||||
required int sessionType,
|
||||
/// get total unread message count
|
||||
/// int.tryParse(count) ?? 0;
|
||||
Future<dynamic> getTotalUnreadMsgCount({
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'getConversationIDBySessionType',
|
||||
'getTotalUnreadMsgCount',
|
||||
_buildParam({
|
||||
"sourceID": sourceID,
|
||||
"sessionType": sessionType,
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}));
|
||||
|
||||
/// Message Do-Not-Disturb Setting
|
||||
@ -333,14 +326,9 @@ class ConversationManager {
|
||||
/// Custom Sort for Conversation List
|
||||
List<ConversationInfo> simpleSort(List<ConversationInfo> list) => list
|
||||
..sort((a, b) {
|
||||
if ((a.isPinned == true && b.isPinned == true) ||
|
||||
(a.isPinned != true && b.isPinned != true)) {
|
||||
int aCompare = a.draftTextTime! > a.latestMsgSendTime!
|
||||
? a.draftTextTime!
|
||||
: a.latestMsgSendTime!;
|
||||
int bCompare = b.draftTextTime! > b.latestMsgSendTime!
|
||||
? b.draftTextTime!
|
||||
: b.latestMsgSendTime!;
|
||||
if ((a.isPinned == true && b.isPinned == true) || (a.isPinned != true && b.isPinned != true)) {
|
||||
int aCompare = a.draftTextTime! > a.latestMsgSendTime! ? a.draftTextTime! : a.latestMsgSendTime!;
|
||||
int bCompare = b.draftTextTime! > b.latestMsgSendTime! ? b.draftTextTime! : b.latestMsgSendTime!;
|
||||
if (aCompare > bCompare) {
|
||||
return -1;
|
||||
} else if (aCompare < bCompare) {
|
||||
|
@ -64,8 +64,7 @@ class IMManager {
|
||||
userManager.listener.selfInfoUpdated(userInfo);
|
||||
break;
|
||||
case 'onUserStatusChanged':
|
||||
final status =
|
||||
Utils.toObj(data, (map) => UserStatusInfo.fromJson(map));
|
||||
final status = Utils.toObj(data, (map) => UserStatusInfo.fromJson(map));
|
||||
userManager.listener.userStatusChanged(status);
|
||||
break;
|
||||
}
|
||||
@ -74,23 +73,19 @@ class IMManager {
|
||||
dynamic data = call.arguments['data'];
|
||||
switch (type) {
|
||||
case 'onGroupApplicationAccepted':
|
||||
final i = Utils.toObj(
|
||||
data, (map) => GroupApplicationInfo.fromJson(map));
|
||||
final i = Utils.toObj(data, (map) => GroupApplicationInfo.fromJson(map));
|
||||
groupManager.listener.groupApplicationAccepted(i);
|
||||
break;
|
||||
case 'onGroupApplicationAdded':
|
||||
final i = Utils.toObj(
|
||||
data, (map) => GroupApplicationInfo.fromJson(map));
|
||||
final i = Utils.toObj(data, (map) => GroupApplicationInfo.fromJson(map));
|
||||
groupManager.listener.groupApplicationAdded(i);
|
||||
break;
|
||||
case 'onGroupApplicationDeleted':
|
||||
final i = Utils.toObj(
|
||||
data, (map) => GroupApplicationInfo.fromJson(map));
|
||||
final i = Utils.toObj(data, (map) => GroupApplicationInfo.fromJson(map));
|
||||
groupManager.listener.groupApplicationDeleted(i);
|
||||
break;
|
||||
case 'onGroupApplicationRejected':
|
||||
final i = Utils.toObj(
|
||||
data, (map) => GroupApplicationInfo.fromJson(map));
|
||||
final i = Utils.toObj(data, (map) => GroupApplicationInfo.fromJson(map));
|
||||
groupManager.listener.groupApplicationRejected(i);
|
||||
break;
|
||||
case 'onGroupDismissed':
|
||||
@ -102,18 +97,15 @@ class IMManager {
|
||||
groupManager.listener.groupInfoChanged(i);
|
||||
break;
|
||||
case 'onGroupMemberAdded':
|
||||
final i =
|
||||
Utils.toObj(data, (map) => GroupMembersInfo.fromJson(map));
|
||||
final i = Utils.toObj(data, (map) => GroupMembersInfo.fromJson(map));
|
||||
groupManager.listener.groupMemberAdded(i);
|
||||
break;
|
||||
case 'onGroupMemberDeleted':
|
||||
final i =
|
||||
Utils.toObj(data, (map) => GroupMembersInfo.fromJson(map));
|
||||
final i = Utils.toObj(data, (map) => GroupMembersInfo.fromJson(map));
|
||||
groupManager.listener.groupMemberDeleted(i);
|
||||
break;
|
||||
case 'onGroupMemberInfoChanged':
|
||||
final i =
|
||||
Utils.toObj(data, (map) => GroupMembersInfo.fromJson(map));
|
||||
final i = Utils.toObj(data, (map) => GroupMembersInfo.fromJson(map));
|
||||
groupManager.listener.groupMemberInfoChanged(i);
|
||||
break;
|
||||
case 'onJoinedGroupAdded':
|
||||
@ -141,22 +133,19 @@ class IMManager {
|
||||
break;
|
||||
case 'onRecvC2CReadReceipt':
|
||||
var value = call.arguments['data']['msgReceiptList'];
|
||||
var list =
|
||||
Utils.toList(value, (map) => ReadReceiptInfo.fromJson(map));
|
||||
var list = Utils.toList(value, (map) => ReadReceiptInfo.fromJson(map));
|
||||
messageManager.msgListener.recvC2CReadReceipt(list);
|
||||
break;
|
||||
case 'onRecvGroupReadReceipt':
|
||||
var value = call.arguments['data']['groupMsgReceiptList'];
|
||||
var list =
|
||||
Utils.toList(value, (map) => ReadReceiptInfo.fromJson(map));
|
||||
var list = Utils.toList(value, (map) => ReadReceiptInfo.fromJson(map));
|
||||
messageManager.msgListener.recvGroupReadReceipt(list);
|
||||
break;
|
||||
case 'onRecvMessageExtensionsDeleted':
|
||||
var msgID = call.arguments['data']['msgID'];
|
||||
var value = call.arguments['data']['reactionExtensionKeyList'];
|
||||
var list = Utils.toList(value, (map) => '$map');
|
||||
messageManager.msgListener
|
||||
.recvMessageExtensionsDeleted(msgID, list);
|
||||
messageManager.msgListener.recvMessageExtensionsDeleted(msgID, list);
|
||||
break;
|
||||
|
||||
case 'onRecvNewMessage':
|
||||
@ -198,18 +187,15 @@ class IMManager {
|
||||
conversationManager.listener.syncServerFailed();
|
||||
break;
|
||||
case 'onNewConversation':
|
||||
var list =
|
||||
Utils.toList(data, (map) => ConversationInfo.fromJson(map));
|
||||
var list = Utils.toList(data, (map) => ConversationInfo.fromJson(map));
|
||||
conversationManager.listener.newConversation(list);
|
||||
break;
|
||||
case 'onConversationChanged':
|
||||
var list =
|
||||
Utils.toList(data, (map) => ConversationInfo.fromJson(map));
|
||||
var list = Utils.toList(data, (map) => ConversationInfo.fromJson(map));
|
||||
conversationManager.listener.conversationChanged(list);
|
||||
break;
|
||||
case 'onTotalUnreadMessageCountChanged':
|
||||
conversationManager.listener
|
||||
.totalUnreadMessageCountChanged(data ?? 0);
|
||||
conversationManager.listener.totalUnreadMessageCountChanged(data ?? 0);
|
||||
break;
|
||||
}
|
||||
} else if (call.method == ListenerType.friendListener) {
|
||||
@ -230,23 +216,19 @@ class IMManager {
|
||||
friendshipManager.listener.friendAdded(u);
|
||||
break;
|
||||
case 'onFriendApplicationAccepted':
|
||||
final u = Utils.toObj(
|
||||
data, (map) => FriendApplicationInfo.fromJson(map));
|
||||
final u = Utils.toObj(data, (map) => FriendApplicationInfo.fromJson(map));
|
||||
friendshipManager.listener.friendApplicationAccepted(u);
|
||||
break;
|
||||
case 'onFriendApplicationAdded':
|
||||
final u = Utils.toObj(
|
||||
data, (map) => FriendApplicationInfo.fromJson(map));
|
||||
final u = Utils.toObj(data, (map) => FriendApplicationInfo.fromJson(map));
|
||||
friendshipManager.listener.friendApplicationAdded(u);
|
||||
break;
|
||||
case 'onFriendApplicationDeleted':
|
||||
final u = Utils.toObj(
|
||||
data, (map) => FriendApplicationInfo.fromJson(map));
|
||||
final u = Utils.toObj(data, (map) => FriendApplicationInfo.fromJson(map));
|
||||
friendshipManager.listener.friendApplicationDeleted(u);
|
||||
break;
|
||||
case 'onFriendApplicationRejected':
|
||||
final u = Utils.toObj(
|
||||
data, (map) => FriendApplicationInfo.fromJson(map));
|
||||
final u = Utils.toObj(data, (map) => FriendApplicationInfo.fromJson(map));
|
||||
friendshipManager.listener.friendApplicationRejected(u);
|
||||
break;
|
||||
case 'onFriendDeleted':
|
||||
@ -263,8 +245,7 @@ class IMManager {
|
||||
String data = call.arguments['data'];
|
||||
switch (type) {
|
||||
case 'onRecvCustomBusinessMessage':
|
||||
messageManager.customBusinessListener
|
||||
?.recvCustomBusinessMessage(data);
|
||||
messageManager.customBusinessListener?.recvCustomBusinessMessage(data);
|
||||
break;
|
||||
}
|
||||
} else if (call.method == ListenerType.listenerForService) {
|
||||
@ -272,23 +253,19 @@ class IMManager {
|
||||
String data = call.arguments['data'];
|
||||
switch (type) {
|
||||
case 'onFriendApplicationAccepted':
|
||||
final u = Utils.toObj(
|
||||
data, (map) => FriendApplicationInfo.fromJson(map));
|
||||
final u = Utils.toObj(data, (map) => FriendApplicationInfo.fromJson(map));
|
||||
_listenerForService?.friendApplicationAccepted(u);
|
||||
break;
|
||||
case 'onFriendApplicationAdded':
|
||||
final u = Utils.toObj(
|
||||
data, (map) => FriendApplicationInfo.fromJson(map));
|
||||
final u = Utils.toObj(data, (map) => FriendApplicationInfo.fromJson(map));
|
||||
_listenerForService?.friendApplicationAdded(u);
|
||||
break;
|
||||
case 'onGroupApplicationAccepted':
|
||||
final i = Utils.toObj(
|
||||
data, (map) => GroupApplicationInfo.fromJson(map));
|
||||
final i = Utils.toObj(data, (map) => GroupApplicationInfo.fromJson(map));
|
||||
_listenerForService?.groupApplicationAccepted(i);
|
||||
break;
|
||||
case 'onGroupApplicationAdded':
|
||||
final i = Utils.toObj(
|
||||
data, (map) => GroupApplicationInfo.fromJson(map));
|
||||
final i = Utils.toObj(data, (map) => GroupApplicationInfo.fromJson(map));
|
||||
_listenerForService?.groupApplicationAdded(i);
|
||||
break;
|
||||
case 'onRecvNewMessage':
|
||||
@ -336,8 +313,7 @@ class IMManager {
|
||||
int fileSize = data['fileSize'];
|
||||
int streamSize = data['streamSize'];
|
||||
int storageSize = data['storageSize'];
|
||||
_uploadFileListener?.uploadProgress(
|
||||
id, fileSize, streamSize, storageSize);
|
||||
_uploadFileListener?.uploadProgress(id, fileSize, streamSize, storageSize);
|
||||
break;
|
||||
case 'uploadID':
|
||||
String id = data['id'];
|
||||
@ -349,14 +325,12 @@ class IMManager {
|
||||
int index = data['index'];
|
||||
int partSize = data['partSize'];
|
||||
String partHash = data['partHash'];
|
||||
_uploadFileListener?.uploadPartComplete(
|
||||
id, index, partSize, partHash);
|
||||
_uploadFileListener?.uploadPartComplete(id, index, partSize, partHash);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (error, stackTrace) {
|
||||
Logger.print(
|
||||
"回调失败了。${call.method} ${call.arguments['type']} ${call.arguments['data']} $error $stackTrace");
|
||||
Logger.print("回调失败了。${call.method} ${call.arguments['type']} ${call.arguments['data']} $error $stackTrace");
|
||||
}
|
||||
return Future.value(null);
|
||||
});
|
||||
@ -526,15 +500,16 @@ class IMManager {
|
||||
/// [fcmToken] Firebase token
|
||||
Future updateFcmToken({
|
||||
required String fcmToken,
|
||||
required int expireTime,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'updateFcmToken',
|
||||
_buildParam({
|
||||
'fcmToken': fcmToken,
|
||||
'expireTime': expireTime,
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}),
|
||||
);
|
||||
}));
|
||||
|
||||
void setUploadFileListener(OnUploadFileListener listener) {
|
||||
_uploadFileListener = listener;
|
||||
|
@ -698,12 +698,14 @@ class MessageManager {
|
||||
required PictureInfo sourcePicture,
|
||||
required PictureInfo bigPicture,
|
||||
required PictureInfo snapshotPicture,
|
||||
String? sourcePath,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'createImageMessageByURL',
|
||||
_buildParam({
|
||||
'sourcePath': sourcePath,
|
||||
'sourcePicture': sourcePicture.toJson(),
|
||||
'bigPicture': bigPicture.toJson(),
|
||||
'snapshotPicture': snapshotPicture.toJson(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user