增加群组通知过滤
This commit is contained in:
13
lib/src/enum/group_notify_filter.dart
Normal file
13
lib/src/enum/group_notify_filter.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
class GroupNotifyFilter {
|
||||
static const notificationVisibleToAll = 0; // 所有人可见 - Visible to all
|
||||
static const notificationVisibleToOperatorAndAdmin =
|
||||
1; // 操作者、被操作者和管理员可见 - Visible to operator, target and admin
|
||||
static const notificationVisibleToAdminOnly =
|
||||
2; // 仅管理员可见 - Visible to admin only
|
||||
static const notificationVisibleToOperatorOnly =
|
||||
3; // 仅操作者本人可见 - Visible to operator only
|
||||
static const notificationVisibleToTargetOnly =
|
||||
4; // 仅被操作者本人可见 - Visible to target only
|
||||
static const notificationVisibleToOperatorAndTarget =
|
||||
5; // 操作者和被操作者可见 - Visible to operator and target
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
import 'package:flutter_openim_sdk/src/logger.dart';
|
||||
|
||||
|
||||
class IMManager {
|
||||
MethodChannel _channel;
|
||||
late ConversationManager conversationManager;
|
||||
@@ -60,7 +59,7 @@ class IMManager {
|
||||
case 'onUserTokenExpired':
|
||||
_connectListener.userTokenExpired();
|
||||
break;
|
||||
case 'onUserTokenInvalid':
|
||||
case 'onUserTokenInvalid':
|
||||
_connectListener.userTokenInvalid();
|
||||
break;
|
||||
}
|
||||
@@ -73,7 +72,8 @@ 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;
|
||||
}
|
||||
@@ -82,19 +82,23 @@ 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':
|
||||
@@ -106,15 +110,18 @@ 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':
|
||||
@@ -130,7 +137,6 @@ class IMManager {
|
||||
String type = call.arguments['type'];
|
||||
dynamic data = call.arguments['data'];
|
||||
switch (type) {
|
||||
|
||||
case 'onChannelDismissed':
|
||||
final i = Utils.toObj(data, (map) => ChannelInfo.fromJson(map));
|
||||
channelManager.listener.channelDismissed(i);
|
||||
@@ -140,18 +146,18 @@ class IMManager {
|
||||
channelManager.listener.channelInfoChanged(i);
|
||||
break;
|
||||
case 'onChannelMemberAdded':
|
||||
final i = Utils.toObj(
|
||||
data, (map) => ChannelMembersInfo.fromJson(map));
|
||||
final i =
|
||||
Utils.toObj(data, (map) => ChannelMembersInfo.fromJson(map));
|
||||
channelManager.listener.channelMemberAdded(i);
|
||||
break;
|
||||
case 'onChannelMemberDeleted':
|
||||
final i = Utils.toObj(
|
||||
data, (map) => ChannelMembersInfo.fromJson(map));
|
||||
final i =
|
||||
Utils.toObj(data, (map) => ChannelMembersInfo.fromJson(map));
|
||||
channelManager.listener.channelMemberDeleted(i);
|
||||
break;
|
||||
case 'onChannelMemberInfoChanged':
|
||||
final i = Utils.toObj(
|
||||
data, (map) => ChannelMembersInfo.fromJson(map));
|
||||
final i =
|
||||
Utils.toObj(data, (map) => ChannelMembersInfo.fromJson(map));
|
||||
channelManager.listener.channelMemberInfoChanged(i);
|
||||
break;
|
||||
case 'onJoinedChannelAdded':
|
||||
@@ -163,7 +169,7 @@ class IMManager {
|
||||
channelManager.listener.joinedChannelDeleted(i);
|
||||
break;
|
||||
}
|
||||
}else if (call.method == ListenerType.advancedMsgListener) {
|
||||
} else if (call.method == ListenerType.advancedMsgListener) {
|
||||
var type = call.arguments['type'];
|
||||
// var id = call.arguments['data']['id'];
|
||||
switch (type) {
|
||||
@@ -184,7 +190,8 @@ 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 'onRecvNewMessage':
|
||||
@@ -234,19 +241,24 @@ class IMManager {
|
||||
conversationManager.listener.syncServerFailed(data);
|
||||
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;
|
||||
case 'onConversationUserInputStatusChanged':
|
||||
final i = Utils.toObj(data, (map) => InputStatusChangedData.fromJson(map));
|
||||
conversationManager.listener.conversationUserInputStatusChanged(i);
|
||||
final i = Utils.toObj(
|
||||
data, (map) => InputStatusChangedData.fromJson(map));
|
||||
conversationManager.listener
|
||||
.conversationUserInputStatusChanged(i);
|
||||
break;
|
||||
}
|
||||
} else if (call.method == ListenerType.friendListener) {
|
||||
@@ -267,19 +279,23 @@ 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':
|
||||
@@ -296,7 +312,8 @@ 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) {
|
||||
@@ -304,19 +321,23 @@ 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':
|
||||
@@ -373,7 +394,8 @@ 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'];
|
||||
@@ -385,12 +407,14 @@ 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);
|
||||
});
|
||||
@@ -622,6 +646,86 @@ class IMManager {
|
||||
}
|
||||
}
|
||||
|
||||
//sdk多了这几个方法,增加一下
|
||||
Future setNotificationVisibilityRule(
|
||||
{required int notificationType,
|
||||
required int visibilityType,
|
||||
String? operationID}) =>
|
||||
_channel.invokeMethod(
|
||||
'setNotificationVisibilityRule',
|
||||
_buildParam({
|
||||
'notificationType': notificationType,
|
||||
'visibilityType': visibilityType,
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}),
|
||||
);
|
||||
Future setNotificationVisibilityRules(
|
||||
{required String rulesJSON, String? operationID}) =>
|
||||
_channel.invokeMethod(
|
||||
'setNotificationVisibilityRules',
|
||||
_buildParam({
|
||||
'rulesJSON': rulesJSON,
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}),
|
||||
);
|
||||
Future getNotificationVisibilityRule(
|
||||
{required int notificationType, String? operationID}) =>
|
||||
_channel.invokeMethod<int>(
|
||||
'getNotificationVisibilityRule',
|
||||
_buildParam({
|
||||
'notificationType': notificationType,
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}),
|
||||
);
|
||||
|
||||
Future<Map<int, int>> getNotificationVisibilityRules(
|
||||
{String? operationID}) async {
|
||||
var result = await _channel.invokeMethod<Map<int, int>>(
|
||||
'getNotificationVisibilityRules',
|
||||
_buildParam({
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}),
|
||||
);
|
||||
return result ?? <int, int>{};
|
||||
}
|
||||
|
||||
Future enableNotificationVisibilityRule(
|
||||
{required int notificationType, String? operationID}) =>
|
||||
_channel.invokeMethod(
|
||||
'enableNotificationVisibilityRule',
|
||||
_buildParam({
|
||||
'notificationType': notificationType,
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}),
|
||||
);
|
||||
Future disableNotificationVisibilityRule(
|
||||
{required int notificationType, String? operationID}) =>
|
||||
_channel.invokeMethod(
|
||||
'disableNotificationVisibilityRule',
|
||||
_buildParam({
|
||||
'notificationType': notificationType,
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}),
|
||||
);
|
||||
|
||||
Future deleteNotificationVisibilityRule(
|
||||
{required int notificationType, String? operationID}) =>
|
||||
_channel.invokeMethod(
|
||||
'deleteNotificationVisibilityRule',
|
||||
_buildParam({
|
||||
'notificationType': notificationType,
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}),
|
||||
);
|
||||
|
||||
Future resetNotificationVisibilityRules({String? operationID}) =>
|
||||
_channel.invokeMethod(
|
||||
'resetNotificationVisibilityRules',
|
||||
_buildParam({
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}),
|
||||
);
|
||||
|
||||
MethodChannel get channel => _channel;
|
||||
|
||||
static Map _buildParam(Map<String, dynamic> param) {
|
||||
|
||||
Reference in New Issue
Block a user