Upgrade
This commit is contained in:
parent
603188d98a
commit
0fbfc70ef1
@ -1,3 +1,9 @@
|
||||
## 1.0.8
|
||||
|
||||
1.Upgrade sdk to 1.4.4. </br>
|
||||
2.New and changed conversation return changed data and no longer return all data. </br>
|
||||
3.New conversation paging method.
|
||||
|
||||
## 1.0.7
|
||||
|
||||
Upgrade sdk to 1.3.4 </br>
|
||||
|
@ -51,5 +51,5 @@ android {
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
implementation 'io.openim:client-sdk:1.3.4@aar'
|
||||
implementation 'io.openim:client-sdk:1.4.4@aar'
|
||||
}
|
@ -16,13 +16,13 @@ public class BaseListener implements Base {
|
||||
|
||||
@Override
|
||||
public void onError(long l, String s) {
|
||||
Log.e("F-OpenIMSD(callback)", s);
|
||||
// Log.e("F-OpenIMSD(callback)", s);
|
||||
CommonUtil.runMainThreadReturnError(result, l, s, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(String s) {
|
||||
Log.i("F-OpenIMSDK(callback)", s);
|
||||
// Log.i("F-OpenIMSDK(callback)", s);
|
||||
CommonUtil.runMainThreadReturn(result, s);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,12 @@ public class ConversationManager extends BaseManager {
|
||||
Open_im_sdk.getAllConversationList(new BaseListener(result));
|
||||
}
|
||||
|
||||
public void getConversationListSplit(MethodCall methodCall, MethodChannel.Result result) {
|
||||
Open_im_sdk.getConversationListSplit(new BaseListener(result),
|
||||
int2long(methodCall, "offset"),
|
||||
int2long(methodCall, "count"));
|
||||
}
|
||||
|
||||
public void getOneConversation(MethodCall methodCall, MethodChannel.Result result) {
|
||||
Open_im_sdk.getOneConversation(
|
||||
value(methodCall, "sourceID"),
|
||||
|
@ -15,6 +15,7 @@ public class ConversationManager: BaseServiceManager {
|
||||
|
||||
self["setConversationListener"] = setConversationListener
|
||||
self["getAllConversationList"] = getAllConversationList
|
||||
self["getConversationListSplit"] = getConversationListSplit
|
||||
self["getOneConversation"] = getOneConversation
|
||||
self["getMultipleConversation"] = getMultipleConversation
|
||||
self["deleteConversation"] = deleteConversation
|
||||
@ -36,7 +37,11 @@ public class ConversationManager: BaseServiceManager {
|
||||
func getAllConversationList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
Open_im_sdkGetAllConversationList(BaseCallback(result: result))
|
||||
}
|
||||
|
||||
|
||||
func getConversationListSplit(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
Open_im_sdkGetConversationListSplit(BaseCallback(result: result), methodCall[int: "offset"], methodCall[int: "count"])
|
||||
}
|
||||
|
||||
func getOneConversation(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
Open_im_sdkGetOneConversation(methodCall[string: "sourceID"], methodCall[int: "sessionType"], BaseCallback(result: result))
|
||||
}
|
||||
@ -75,7 +80,7 @@ public class ConversationManager: BaseServiceManager {
|
||||
}
|
||||
|
||||
func setConversationRecvMessageOpt(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
Open_im_sdkSetConversationRecvMessageOpt(BaseCallback(result: result), methodCall[jsonString: "conversationIDList"], Int(methodCall[int64: "status"]))
|
||||
Open_im_sdkSetConversationRecvMessageOpt(BaseCallback(result: result), methodCall[jsonString: "conversationIDList"], methodCall[int: "status"])
|
||||
}
|
||||
|
||||
func getConversationRecvMessageOpt(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
|
@ -941,6 +941,7 @@
|
||||
- (void)getBlackList:(id<Open_im_sdkBase> _Nullable)callback;
|
||||
// skipped method UserRelated.GetCh with unsupported parameter or return types
|
||||
|
||||
- (void)getConversationListSplit:(id<Open_im_sdkBase> _Nullable)callback offset:(long)offset count:(long)count;
|
||||
- (void)getConversationRecvMessageOpt:(id<Open_im_sdkBase> _Nullable)callback conversationIDList:(NSString* _Nullable)conversationIDList;
|
||||
- (void)getFriendApplicationList:(id<Open_im_sdkBase> _Nullable)callback;
|
||||
- (void)getFriendList:(id<Open_im_sdkBase> _Nullable)callback;
|
||||
@ -1157,8 +1158,6 @@ FOUNDATION_EXPORT NSString* _Nonnull const Open_im_sdkCmdReLogin;
|
||||
FOUNDATION_EXPORT NSString* _Nonnull const Open_im_sdkCmdRefuseFriend;
|
||||
FOUNDATION_EXPORT NSString* _Nonnull const Open_im_sdkCmdUnInit;
|
||||
FOUNDATION_EXPORT NSString* _Nonnull const Open_im_sdkCmdUpdateConversation;
|
||||
FOUNDATION_EXPORT const int64_t Open_im_sdkConAndUnreadChange;
|
||||
FOUNDATION_EXPORT const int64_t Open_im_sdkConChange;
|
||||
FOUNDATION_EXPORT const int64_t Open_im_sdkCreateGroupTip;
|
||||
FOUNDATION_EXPORT const int64_t Open_im_sdkCustom;
|
||||
FOUNDATION_EXPORT NSString* _Nonnull const Open_im_sdkDeFaultSuccessMsg;
|
||||
@ -1207,9 +1206,13 @@ FOUNDATION_EXPORT const int64_t Open_im_sdkMsgStatusSendSuccess;
|
||||
* MsgStatus
|
||||
*/
|
||||
FOUNDATION_EXPORT const int64_t Open_im_sdkMsgStatusSending;
|
||||
FOUNDATION_EXPORT const int64_t Open_im_sdkNewCon;
|
||||
FOUNDATION_EXPORT const int64_t Open_im_sdkNewConChange;
|
||||
FOUNDATION_EXPORT const int64_t Open_im_sdkNotPinned;
|
||||
FOUNDATION_EXPORT const int64_t Open_im_sdkNotRead;
|
||||
FOUNDATION_EXPORT const int64_t Open_im_sdkNotReceiveMessage;
|
||||
FOUNDATION_EXPORT const int64_t Open_im_sdkPicture;
|
||||
FOUNDATION_EXPORT const int64_t Open_im_sdkPinned;
|
||||
FOUNDATION_EXPORT const int64_t Open_im_sdkQuitGroupTip;
|
||||
FOUNDATION_EXPORT const int64_t Open_im_sdkQuote;
|
||||
/**
|
||||
@ -1536,6 +1539,8 @@ FOUNDATION_EXPORT void Open_im_sdkGetBlackList(id<Open_im_sdkBase> _Nullable cal
|
||||
|
||||
FOUNDATION_EXPORT NSString* _Nonnull Open_im_sdkGetConversationIDBySessionType(NSString* _Nullable sourceID, long sessionType);
|
||||
|
||||
FOUNDATION_EXPORT void Open_im_sdkGetConversationListSplit(id<Open_im_sdkBase> _Nullable callback, long offset, long count);
|
||||
|
||||
FOUNDATION_EXPORT void Open_im_sdkGetConversationRecvMessageOpt(id<Open_im_sdkBase> _Nullable callback, NSString* _Nullable conversationIDList);
|
||||
|
||||
/**
|
||||
@ -1686,6 +1691,8 @@ FOUNDATION_EXPORT void Open_im_sdkSetGroupInfo(NSString* _Nullable jsonGroupInfo
|
||||
|
||||
FOUNDATION_EXPORT void Open_im_sdkSetGroupListener(id<Open_im_sdkOnGroupListener> _Nullable callback);
|
||||
|
||||
FOUNDATION_EXPORT void Open_im_sdkSetHearbeatInterval(int32_t interval);
|
||||
|
||||
/**
|
||||
* 1 no print
|
||||
*/
|
||||
|
Binary file not shown.
@ -8,6 +8,7 @@ import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
class ConversationManager {
|
||||
MethodChannel _channel;
|
||||
late ConversationListener conversationListener;
|
||||
var count = 0;
|
||||
|
||||
ConversationManager(this._channel);
|
||||
|
||||
@ -22,6 +23,20 @@ class ConversationManager {
|
||||
.invokeMethod('getAllConversationList', _buildParam({}))
|
||||
.then((value) => _toList(value));
|
||||
|
||||
/// Paging to get conversation
|
||||
Future<List<ConversationInfo>> getConversationListSplit({
|
||||
int offset = 0,
|
||||
int count = 20,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'getConversationListSplit',
|
||||
_buildParam({
|
||||
'offset': offset,
|
||||
'count': count,
|
||||
}))
|
||||
.then((value) => _toList(value));
|
||||
|
||||
/// Get a single conversation info
|
||||
/// [sourceID] if it is a single chat, Its value is userID. if it is a group chat, Its value is groupID
|
||||
/// [sessionType] if it is a single chat, it value is 1. if it is a group chat, it value is 2
|
||||
@ -91,21 +106,18 @@ class ConversationManager {
|
||||
.then((value) => _printValue(value));
|
||||
|
||||
/// Mark single chat messages as read
|
||||
Future<dynamic> markSingleMessageHasRead({required String userID}) {
|
||||
return _channel.invokeMethod(
|
||||
'markSingleMessageHasRead', _buildParam({'userID': userID}));
|
||||
}
|
||||
Future<dynamic> markSingleMessageHasRead({required String userID}) =>
|
||||
_channel.invokeMethod(
|
||||
'markSingleMessageHasRead', _buildParam({'userID': userID}));
|
||||
|
||||
/// Mark group chat messages as read
|
||||
Future<dynamic> markGroupMessageHasRead({required String groupID}) {
|
||||
return _channel.invokeMethod(
|
||||
'markGroupMessageHasRead', _buildParam({'groupID': groupID}));
|
||||
}
|
||||
Future<dynamic> markGroupMessageHasRead({required String groupID}) =>
|
||||
_channel.invokeMethod(
|
||||
'markGroupMessageHasRead', _buildParam({'groupID': groupID}));
|
||||
|
||||
/// Get the total number of unread messages
|
||||
Future<dynamic> getTotalUnreadMsgCount() {
|
||||
return _channel.invokeMethod('getTotalUnreadMsgCount', _buildParam({}));
|
||||
}
|
||||
Future<dynamic> getTotalUnreadMsgCount() =>
|
||||
_channel.invokeMethod('getTotalUnreadMsgCount', _buildParam({}));
|
||||
|
||||
/// Query conversation id
|
||||
/// [sourceID] : if it is a single chat, Its value is userID. if it is a group chat, Its value is groupID
|
||||
@ -113,42 +125,64 @@ class ConversationManager {
|
||||
Future<dynamic> getConversationID({
|
||||
required String sourceID,
|
||||
required int sessionType,
|
||||
}) {
|
||||
return _channel.invokeMethod(
|
||||
'getConversationIDBySessionType',
|
||||
_buildParam({
|
||||
"sourceID": sourceID,
|
||||
"sessionType": sessionType,
|
||||
}));
|
||||
}
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'getConversationIDBySessionType',
|
||||
_buildParam({
|
||||
"sourceID": sourceID,
|
||||
"sessionType": sessionType,
|
||||
}));
|
||||
|
||||
/// Message Do Not Disturb
|
||||
/// [ status ] 1: Do not receive messages, 2: Do not notify when messages are received; 0: Normal
|
||||
Future<dynamic> setConversationRecvMessageOpt({
|
||||
required List<String> conversationIDList,
|
||||
required int status,
|
||||
}) {
|
||||
return _channel.invokeMethod(
|
||||
'setConversationRecvMessageOpt',
|
||||
_buildParam({
|
||||
"conversationIDList": conversationIDList,
|
||||
"status": status,
|
||||
}));
|
||||
}
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'setConversationRecvMessageOpt',
|
||||
_buildParam({
|
||||
"conversationIDList": conversationIDList,
|
||||
"status": status,
|
||||
}));
|
||||
|
||||
/// Message Do Not Disturb
|
||||
/// [{"conversationId":"single_13922222222","result":0}]
|
||||
Future<List<dynamic>> getConversationRecvMessageOpt({
|
||||
required List<String> conversationIDList,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'getConversationRecvMessageOpt',
|
||||
_buildParam({
|
||||
"conversationIDList": conversationIDList,
|
||||
}))
|
||||
.then((value) => _formatJson(value));
|
||||
}
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'getConversationRecvMessageOpt',
|
||||
_buildParam({
|
||||
"conversationIDList": conversationIDList,
|
||||
}))
|
||||
.then((value) => _formatJson(value));
|
||||
|
||||
/// Custom sort for conversation list
|
||||
List<ConversationInfo> simpleSort(List<ConversationInfo> list) => list
|
||||
..sort((a, b) {
|
||||
if ((a.isPinned == 1 && b.isPinned == 1) ||
|
||||
(a.isPinned != 1 && b.isPinned != 1)) {
|
||||
int aCompare = a.draftTimestamp! > a.latestMsgSendTime!
|
||||
? a.draftTimestamp!
|
||||
: a.latestMsgSendTime!;
|
||||
int bCompare = b.draftTimestamp! > b.latestMsgSendTime!
|
||||
? b.draftTimestamp!
|
||||
: b.latestMsgSendTime!;
|
||||
if (aCompare > bCompare) {
|
||||
return -1;
|
||||
} else if (aCompare < bCompare) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else if (a.isPinned == 1 && b.isPinned != 1) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
static Map _buildParam(Map param) {
|
||||
param["ManagerName"] = "conversationManager";
|
||||
@ -164,9 +198,7 @@ class ConversationManager {
|
||||
static ConversationInfo _toObj(String value) =>
|
||||
ConversationInfo.fromJson(_formatJson(value));
|
||||
|
||||
static dynamic _formatJson(value) {
|
||||
return jsonDecode(_printValue(value));
|
||||
}
|
||||
static dynamic _formatJson(value) => jsonDecode(_printValue(value));
|
||||
|
||||
static String _printValue(value) {
|
||||
return value;
|
||||
|
@ -16,92 +16,70 @@ class FriendshipManager {
|
||||
}
|
||||
|
||||
/// Get friend info by user id
|
||||
Future<List<UserInfo>> getFriendsInfo({required List<String> uidList}) {
|
||||
return _channel
|
||||
.invokeMethod('getFriendsInfo', _buildParam({"uidList": uidList}))
|
||||
.then((value) => _toList(value));
|
||||
}
|
||||
Future<List<UserInfo>> getFriendsInfo({required List<String> uidList}) =>
|
||||
_channel
|
||||
.invokeMethod('getFriendsInfo', _buildParam({"uidList": uidList}))
|
||||
.then((value) => _toList(value));
|
||||
|
||||
/// Send an friend application
|
||||
Future<dynamic> addFriend({required String uid, required String reason}) {
|
||||
return _channel.invokeMethod(
|
||||
'addFriend', _buildParam({"uid": uid, "reqMessage": reason}));
|
||||
}
|
||||
Future<dynamic> addFriend({required String uid, required String reason}) =>
|
||||
_channel.invokeMethod(
|
||||
'addFriend', _buildParam({"uid": uid, "reqMessage": reason}));
|
||||
|
||||
/// Get all friend application, sent to you by others
|
||||
Future<List<UserInfo>> getFriendApplicationList() {
|
||||
return _channel
|
||||
.invokeMethod('getFriendApplicationList', _buildParam({}))
|
||||
.then((value) => _toList(value));
|
||||
}
|
||||
Future<List<UserInfo>> getFriendApplicationList() => _channel
|
||||
.invokeMethod('getFriendApplicationList', _buildParam({}))
|
||||
.then((value) => _toList(value));
|
||||
|
||||
/// Find all friends including those who have been added to the blacklist
|
||||
Future<List<UserInfo>> getFriendList() {
|
||||
return _channel
|
||||
.invokeMethod('getFriendList', _buildParam({}))
|
||||
.then((value) => _toList(value));
|
||||
}
|
||||
Future<List<UserInfo>> getFriendList() => _channel
|
||||
.invokeMethod('getFriendList', _buildParam({}))
|
||||
.then((value) => _toList(value));
|
||||
|
||||
/// Find all friends including those who have been added to the blacklist
|
||||
Future<List<dynamic>> getFriendListMap() {
|
||||
return _channel
|
||||
.invokeMethod('getFriendList', _buildParam({}))
|
||||
.then((value) => _toListMap(value));
|
||||
}
|
||||
Future<List<dynamic>> getFriendListMap() => _channel
|
||||
.invokeMethod('getFriendList', _buildParam({}))
|
||||
.then((value) => _toListMap(value));
|
||||
|
||||
/// Modify friend information, only [comment] can be modified
|
||||
Future<dynamic> setFriendInfo(
|
||||
{required String uid, required String comment}) {
|
||||
return _channel.invokeMethod(
|
||||
'setFriendInfo',
|
||||
_buildParam({
|
||||
'uid': uid,
|
||||
'comment': comment,
|
||||
}));
|
||||
}
|
||||
{required String uid, required String comment}) =>
|
||||
_channel.invokeMethod(
|
||||
'setFriendInfo',
|
||||
_buildParam({
|
||||
'uid': uid,
|
||||
'comment': comment,
|
||||
}));
|
||||
|
||||
/// Add friends to blacklist
|
||||
Future<dynamic> addToBlackList({required String uid}) {
|
||||
return _channel.invokeMethod('addToBlackList', _buildParam({"uid": uid}));
|
||||
}
|
||||
Future<dynamic> addToBlackList({required String uid}) =>
|
||||
_channel.invokeMethod('addToBlackList', _buildParam({"uid": uid}));
|
||||
|
||||
/// Find all blacklist
|
||||
Future<List<UserInfo>> getBlackList() {
|
||||
return _channel
|
||||
.invokeMethod('getBlackList', _buildParam({}))
|
||||
.then((value) => _toList(value));
|
||||
}
|
||||
Future<List<UserInfo>> getBlackList() => _channel
|
||||
.invokeMethod('getBlackList', _buildParam({}))
|
||||
.then((value) => _toList(value));
|
||||
|
||||
/// Remove from blacklist
|
||||
Future<dynamic> deleteFromBlackList({required String uid}) {
|
||||
return _channel.invokeMethod(
|
||||
'deleteFromBlackList', _buildParam({"uid": uid}));
|
||||
}
|
||||
Future<dynamic> deleteFromBlackList({required String uid}) =>
|
||||
_channel.invokeMethod('deleteFromBlackList', _buildParam({"uid": uid}));
|
||||
|
||||
/// Determine if there is a friendship by userId
|
||||
Future<List<UserInfo>> checkFriend(List<String> uidList) {
|
||||
return _channel
|
||||
.invokeMethod('checkFriend', _buildParam({'uidList': uidList}))
|
||||
.then((value) => _toList(value));
|
||||
}
|
||||
Future<List<UserInfo>> checkFriend(List<String> uidList) => _channel
|
||||
.invokeMethod('checkFriend', _buildParam({'uidList': uidList}))
|
||||
.then((value) => _toList(value));
|
||||
|
||||
/// Dissolve friendship from friend list
|
||||
Future<dynamic> deleteFromFriendList({required String uid}) {
|
||||
return _channel.invokeMethod(
|
||||
'deleteFromFriendList', _buildParam({"uid": uid}));
|
||||
}
|
||||
Future<dynamic> deleteFromFriendList({required String uid}) =>
|
||||
_channel.invokeMethod('deleteFromFriendList', _buildParam({"uid": uid}));
|
||||
|
||||
/// Accept application of be friend
|
||||
Future<dynamic> acceptFriendApplication({required String uid}) {
|
||||
return _channel.invokeMethod(
|
||||
'acceptFriendApplication', _buildParam({"uid": uid}));
|
||||
}
|
||||
Future<dynamic> acceptFriendApplication({required String uid}) => _channel
|
||||
.invokeMethod('acceptFriendApplication', _buildParam({"uid": uid}));
|
||||
|
||||
/// Refuse application of be friend
|
||||
Future<dynamic> refuseFriendApplication({required String uid}) {
|
||||
return _channel.invokeMethod(
|
||||
'refuseFriendApplication', _buildParam({"uid": uid}));
|
||||
}
|
||||
Future<dynamic> refuseFriendApplication({required String uid}) => _channel
|
||||
.invokeMethod('refuseFriendApplication', _buildParam({"uid": uid}));
|
||||
|
||||
///
|
||||
// Future<dynamic> forceSyncFriendApplication() {
|
||||
@ -136,9 +114,7 @@ class FriendshipManager {
|
||||
|
||||
// static UserInfo _toObj(String value) => UserInfo.fromJson(_formatJson(value));
|
||||
|
||||
static dynamic _formatJson(value) {
|
||||
return jsonDecode(_printValue(value));
|
||||
}
|
||||
static dynamic _formatJson(value) => jsonDecode(_printValue(value));
|
||||
|
||||
static String _printValue(value) {
|
||||
return value;
|
||||
|
@ -21,55 +21,52 @@ class GroupManager {
|
||||
required String groupId,
|
||||
required List<String> uidList,
|
||||
String? reason,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'inviteUserToGroup',
|
||||
_buildParam({
|
||||
'gid': groupId,
|
||||
'reason': reason,
|
||||
'uidList': uidList,
|
||||
}))
|
||||
.then((value) => (_formatJson(value) as List)
|
||||
.map((e) => GroupInviteResult.fromJson(e))
|
||||
.toList());
|
||||
}
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'inviteUserToGroup',
|
||||
_buildParam({
|
||||
'gid': groupId,
|
||||
'reason': reason,
|
||||
'uidList': uidList,
|
||||
}))
|
||||
.then((value) => (_formatJson(value) as List)
|
||||
.map((e) => GroupInviteResult.fromJson(e))
|
||||
.toList());
|
||||
|
||||
/// Remove member from group
|
||||
Future<List<GroupInviteResult>> kickGroupMember({
|
||||
required String groupId,
|
||||
required List<String> uidList,
|
||||
String? reason,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'kickGroupMember',
|
||||
_buildParam({
|
||||
'gid': groupId,
|
||||
'reason': reason,
|
||||
'uidList': uidList,
|
||||
}))
|
||||
.then((value) => (_formatJson(value) as List)
|
||||
.map((e) => GroupInviteResult.fromJson(e))
|
||||
.toList());
|
||||
}
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'kickGroupMember',
|
||||
_buildParam({
|
||||
'gid': groupId,
|
||||
'reason': reason,
|
||||
'uidList': uidList,
|
||||
}))
|
||||
.then((value) => (_formatJson(value) as List)
|
||||
.map((e) => GroupInviteResult.fromJson(e))
|
||||
.toList());
|
||||
|
||||
/// Get group member's info
|
||||
Future<List<GroupMembersInfo>> getGroupMembersInfo({
|
||||
required String groupId,
|
||||
required List<String> uidList,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'getGroupMembersInfo',
|
||||
_buildParam({
|
||||
'gid': groupId,
|
||||
'uidList': uidList,
|
||||
}))
|
||||
.then((value) => (_formatJson(value) as List)
|
||||
.map((e) => GroupMembersInfo.fromJson(e))
|
||||
.toList());
|
||||
}
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'getGroupMembersInfo',
|
||||
_buildParam({
|
||||
'gid': groupId,
|
||||
'uidList': uidList,
|
||||
}))
|
||||
.then((value) => (_formatJson(value) as List)
|
||||
.map((e) => GroupMembersInfo.fromJson(e))
|
||||
.toList());
|
||||
|
||||
/// Get the list of group members
|
||||
/// [filter] 0: all user, 1: group owner, 2: administrator
|
||||
@ -78,55 +75,48 @@ class GroupManager {
|
||||
required String groupId,
|
||||
int filter = 0,
|
||||
int next = 0,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'getGroupMemberList',
|
||||
_buildParam({
|
||||
'gid': groupId,
|
||||
'filter': filter,
|
||||
'next': next,
|
||||
}))
|
||||
.then((value) => GroupMembersList.fromJson(_formatJson(value)));
|
||||
}
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'getGroupMemberList',
|
||||
_buildParam({
|
||||
'gid': groupId,
|
||||
'filter': filter,
|
||||
'next': next,
|
||||
}))
|
||||
.then((value) => GroupMembersList.fromJson(_formatJson(value)));
|
||||
|
||||
/// Get the list of group members
|
||||
Future<dynamic> getGroupMemberListMap({
|
||||
required String groupId,
|
||||
int filter = 0,
|
||||
int next = 0,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'getGroupMemberList',
|
||||
_buildParam({
|
||||
'gid': groupId,
|
||||
'filter': filter,
|
||||
'next': next,
|
||||
}))
|
||||
.then((value) => _formatJson(value));
|
||||
}
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'getGroupMemberList',
|
||||
_buildParam({
|
||||
'gid': groupId,
|
||||
'filter': filter,
|
||||
'next': next,
|
||||
}))
|
||||
.then((value) => _formatJson(value));
|
||||
|
||||
/// Find all groups you have joined
|
||||
Future<List<GroupInfo>> getJoinedGroupList() {
|
||||
return _channel.invokeMethod('getJoinedGroupList', _buildParam({})).then(
|
||||
(value) => (_formatJson(value) as List)
|
||||
.map((e) => GroupInfo.fromJson(e))
|
||||
.toList());
|
||||
}
|
||||
Future<List<GroupInfo>> getJoinedGroupList() => _channel
|
||||
.invokeMethod('getJoinedGroupList', _buildParam({}))
|
||||
.then((value) => (_formatJson(value) as List)
|
||||
.map((e) => GroupInfo.fromJson(e))
|
||||
.toList());
|
||||
|
||||
/// Find all groups you have joined
|
||||
Future<List<dynamic>> getJoinedGroupListMap() {
|
||||
return _channel
|
||||
.invokeMethod('getJoinedGroupList', _buildParam({}))
|
||||
.then((value) => _formatJson(value));
|
||||
}
|
||||
Future<List<dynamic>> getJoinedGroupListMap() => _channel
|
||||
.invokeMethod('getJoinedGroupList', _buildParam({}))
|
||||
.then((value) => _formatJson(value));
|
||||
|
||||
/// Check if you are a member of the group
|
||||
Future<bool> isJoinedGroup({required String gid}) {
|
||||
return getJoinedGroupList()
|
||||
.then((list) => list.where((e) => e.groupID == gid).length > 0);
|
||||
}
|
||||
Future<bool> isJoinedGroup({required String gid}) => getJoinedGroupList()
|
||||
.then((list) => list.where((e) => e.groupID == gid).length > 0);
|
||||
|
||||
/// Create a group
|
||||
Future<dynamic> createGroup({
|
||||
@ -135,20 +125,18 @@ class GroupManager {
|
||||
String? introduction,
|
||||
String? faceUrl,
|
||||
required List<GroupMemberRole> list,
|
||||
}) {
|
||||
return _channel.invokeMethod(
|
||||
'createGroup',
|
||||
_buildParam({
|
||||
'gInfo': {
|
||||
"groupName": groupName,
|
||||
"notification": notification,
|
||||
"introduction": introduction,
|
||||
"faceUrl": faceUrl,
|
||||
},
|
||||
'memberList': list.map((e) => e.toJson()).toList()
|
||||
}));
|
||||
/*.then((value) => _formatJson(value)['groupID'])*/
|
||||
}
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'createGroup',
|
||||
_buildParam({
|
||||
'gInfo': {
|
||||
"groupName": groupName,
|
||||
"notification": notification,
|
||||
"introduction": introduction,
|
||||
"faceUrl": faceUrl,
|
||||
},
|
||||
'memberList': list.map((e) => e.toJson()).toList()
|
||||
}));
|
||||
|
||||
/// Edit group information
|
||||
Future<dynamic> setGroupInfo({
|
||||
@ -157,101 +145,92 @@ class GroupManager {
|
||||
String? notification,
|
||||
String? introduction,
|
||||
String? faceUrl,
|
||||
}) {
|
||||
return _channel.invokeMethod(
|
||||
'setGroupInfo',
|
||||
_buildParam({
|
||||
'gInfo': {
|
||||
"groupID": groupID,
|
||||
"groupName": groupName,
|
||||
"notification": notification,
|
||||
"introduction": introduction,
|
||||
"faceUrl": faceUrl,
|
||||
},
|
||||
}));
|
||||
}
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'setGroupInfo',
|
||||
_buildParam({
|
||||
'gInfo': {
|
||||
"groupID": groupID,
|
||||
"groupName": groupName,
|
||||
"notification": notification,
|
||||
"introduction": introduction,
|
||||
"faceUrl": faceUrl,
|
||||
},
|
||||
}));
|
||||
|
||||
/// Find group information by group id
|
||||
Future<List<GroupInfo>> getGroupsInfo({
|
||||
required List<String> gidList,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod('getGroupsInfo', _buildParam({'gidList': gidList}))
|
||||
.then((value) {
|
||||
List list = _formatJson(value);
|
||||
return list.map((e) => GroupInfo.fromJson(e)).toList();
|
||||
});
|
||||
}
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod('getGroupsInfo', _buildParam({'gidList': gidList}))
|
||||
.then((value) {
|
||||
List list = _formatJson(value);
|
||||
return list.map((e) => GroupInfo.fromJson(e)).toList();
|
||||
});
|
||||
|
||||
/// Apply to join the group
|
||||
Future<dynamic> joinGroup({
|
||||
required String gid,
|
||||
String? reason,
|
||||
}) {
|
||||
return _channel.invokeMethod(
|
||||
'joinGroup',
|
||||
_buildParam({
|
||||
'gid': gid,
|
||||
'reason': reason,
|
||||
}));
|
||||
}
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'joinGroup',
|
||||
_buildParam({
|
||||
'gid': gid,
|
||||
'reason': reason,
|
||||
}));
|
||||
|
||||
/// Leave group
|
||||
Future<dynamic> quitGroup({
|
||||
required String gid,
|
||||
}) {
|
||||
return _channel.invokeMethod(
|
||||
'quitGroup',
|
||||
_buildParam({
|
||||
'gid': gid,
|
||||
}));
|
||||
}
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'quitGroup',
|
||||
_buildParam({
|
||||
'gid': gid,
|
||||
}));
|
||||
|
||||
/// Give group permissions to others
|
||||
Future<dynamic> transferGroupOwner({
|
||||
required String gid,
|
||||
required String uid,
|
||||
}) {
|
||||
return _channel.invokeMethod(
|
||||
'transferGroupOwner',
|
||||
_buildParam({
|
||||
'gid': gid,
|
||||
'uid': uid,
|
||||
}));
|
||||
}
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'transferGroupOwner',
|
||||
_buildParam({
|
||||
'gid': gid,
|
||||
'uid': uid,
|
||||
}));
|
||||
|
||||
/// Get the list of applications
|
||||
Future<GroupApplicationList> getGroupApplicationList() {
|
||||
return _channel
|
||||
.invokeMethod('getGroupApplicationList', _buildParam({}))
|
||||
.then((value) => GroupApplicationList.fromJson(_formatJson(value)));
|
||||
}
|
||||
Future<GroupApplicationList> getGroupApplicationList() => _channel
|
||||
.invokeMethod('getGroupApplicationList', _buildParam({}))
|
||||
.then((value) => GroupApplicationList.fromJson(_formatJson(value)));
|
||||
|
||||
/// Accept group application
|
||||
Future<dynamic> acceptGroupApplication({
|
||||
required GroupApplicationInfo info,
|
||||
required String reason,
|
||||
}) {
|
||||
return _channel.invokeMethod(
|
||||
'acceptGroupApplication',
|
||||
_buildParam({
|
||||
'application': info.toJson(),
|
||||
'reason': reason,
|
||||
}));
|
||||
}
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'acceptGroupApplication',
|
||||
_buildParam({
|
||||
'application': info.toJson(),
|
||||
'reason': reason,
|
||||
}));
|
||||
|
||||
/// Refuse group application
|
||||
Future<dynamic> refuseGroupApplication({
|
||||
required GroupApplicationInfo info,
|
||||
required String reason,
|
||||
}) {
|
||||
return _channel.invokeMethod(
|
||||
'refuseGroupApplication',
|
||||
_buildParam({
|
||||
'application': info.toJson(),
|
||||
'reason': reason,
|
||||
}));
|
||||
}
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'refuseGroupApplication',
|
||||
_buildParam({
|
||||
'application': info.toJson(),
|
||||
'reason': reason,
|
||||
}));
|
||||
|
||||
///
|
||||
// Future forceSyncApplyGroupRequest() {
|
||||
@ -278,9 +257,7 @@ class GroupManager {
|
||||
return param;
|
||||
}
|
||||
|
||||
static dynamic _formatJson(value) {
|
||||
return jsonDecode(_printValue(value));
|
||||
}
|
||||
static dynamic _formatJson(value) => jsonDecode(_printValue(value));
|
||||
|
||||
static String _printValue(value) {
|
||||
return value;
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
|
||||
@ -31,7 +32,7 @@ class IMManager {
|
||||
void _addNativeCallback(MethodChannel _channel) {
|
||||
_channel.setMethodCallHandler((call) {
|
||||
try {
|
||||
print('call:$call');
|
||||
log('Flutter : $call');
|
||||
if (call.method == ListenerType.initSDKListener) {
|
||||
String type = call.arguments['type'];
|
||||
dynamic data = call.arguments['data'];
|
||||
@ -187,7 +188,6 @@ class IMManager {
|
||||
} else if (call.method == ListenerType.conversationListener) {
|
||||
String type = call.arguments['type'];
|
||||
dynamic data = call.arguments['data'];
|
||||
print('type:$type data:$data');
|
||||
switch (type) {
|
||||
case 'onSyncServerStart':
|
||||
conversationManager.conversationListener.syncServerStart();
|
||||
@ -325,63 +325,50 @@ class IMManager {
|
||||
}
|
||||
|
||||
///
|
||||
Future<int?> getLoginStatus() {
|
||||
return _channel.invokeMethod<int>('getLoginStatus', _buildParam({}));
|
||||
}
|
||||
Future<int?> getLoginStatus() =>
|
||||
_channel.invokeMethod<int>('getLoginStatus', _buildParam({}));
|
||||
|
||||
/// Current user id
|
||||
Future<String?> getLoginUid() {
|
||||
return Future.value(uid);
|
||||
// return _channel.invokeMethod<String>('getLoginUid', _buildParam({}));
|
||||
}
|
||||
Future<String?> getLoginUid() => Future.value(uid);
|
||||
|
||||
/// Current user info
|
||||
Future<UserInfo> getLoginUserInfo() {
|
||||
return Future.value(uInfo);
|
||||
}
|
||||
Future<UserInfo> getLoginUserInfo() => Future.value(uInfo);
|
||||
|
||||
/// Modify current user info
|
||||
Future<String?> setSelfInfo(
|
||||
{required String uid,
|
||||
String? name,
|
||||
String? icon,
|
||||
int? gender,
|
||||
String? mobile,
|
||||
String? birth,
|
||||
String? email,
|
||||
String? ex}) {
|
||||
return _channel.invokeMethod(
|
||||
'setSelfInfo',
|
||||
_buildParam({
|
||||
'uid': uid,
|
||||
'name': name,
|
||||
'icon': icon,
|
||||
'gender': gender,
|
||||
'mobile': mobile,
|
||||
'birth': birth,
|
||||
'email': email,
|
||||
'ex': ex,
|
||||
}));
|
||||
// .then((value) => UserInfo.fromJson(value));
|
||||
}
|
||||
{required String uid,
|
||||
String? name,
|
||||
String? icon,
|
||||
int? gender,
|
||||
String? mobile,
|
||||
String? birth,
|
||||
String? email,
|
||||
String? ex}) =>
|
||||
_channel.invokeMethod(
|
||||
'setSelfInfo',
|
||||
_buildParam({
|
||||
'uid': uid,
|
||||
'name': name,
|
||||
'icon': icon,
|
||||
'gender': gender,
|
||||
'mobile': mobile,
|
||||
'birth': birth,
|
||||
'email': email,
|
||||
'ex': ex,
|
||||
}));
|
||||
|
||||
/// Query user information
|
||||
Future<List<UserInfo>> getUsersInfo(List<String> uidList) {
|
||||
return _channel
|
||||
.invokeMethod('getUsersInfo', _buildParam({'uidList': uidList}))
|
||||
.then((value) => _toList(value));
|
||||
}
|
||||
Future<List<UserInfo>> getUsersInfo(List<String> uidList) => _channel
|
||||
.invokeMethod('getUsersInfo', _buildParam({'uidList': uidList}))
|
||||
.then((value) => _toList(value));
|
||||
|
||||
///
|
||||
void enabledSDKLog({required bool enabled}) {
|
||||
_channel.invokeMethod(
|
||||
'setSdkLog', _buildParam({'sdkLog': enabled ? 0 : 1}));
|
||||
}
|
||||
Future enabledSDKLog({required bool enabled}) => _channel.invokeMethod(
|
||||
'setSdkLog', _buildParam({'sdkLog': enabled ? 0 : 1}));
|
||||
|
||||
///
|
||||
Future<dynamic> forceSyncLoginUerInfo(List<String> uidList) {
|
||||
return _channel.invokeMethod('forceSyncLoginUerInfo', _buildParam({}));
|
||||
}
|
||||
Future<dynamic> forceSyncLoginUerInfo(List<String> uidList) =>
|
||||
_channel.invokeMethod('forceSyncLoginUerInfo', _buildParam({}));
|
||||
|
||||
///
|
||||
// Future<dynamic> forceReConn() {
|
||||
@ -396,9 +383,7 @@ class IMManager {
|
||||
static List<UserInfo> _toList(String value) =>
|
||||
(_formatJson(value) as List).map((e) => UserInfo.fromJson(e)).toList();
|
||||
|
||||
static dynamic _formatJson(value) {
|
||||
return jsonDecode(_printValue(value));
|
||||
}
|
||||
static dynamic _formatJson(value) => jsonDecode(_printValue(value));
|
||||
|
||||
static String _printValue(value) {
|
||||
return value;
|
||||
|
@ -43,16 +43,15 @@ class MessageManager {
|
||||
String? userID,
|
||||
String? groupID,
|
||||
bool onlineUserOnly = false,
|
||||
}) {
|
||||
return _channel.invokeMethod(
|
||||
'sendMessage',
|
||||
_buildParam({
|
||||
'message': message.toJson(),
|
||||
'receiver': userID ?? '',
|
||||
'groupID': groupID ?? '',
|
||||
'onlineUserOnly': onlineUserOnly,
|
||||
})) /*.then((value) => _toObj(value))*/;
|
||||
}
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'sendMessage',
|
||||
_buildParam({
|
||||
'message': message.toJson(),
|
||||
'receiver': userID ?? '',
|
||||
'groupID': groupID ?? '',
|
||||
'onlineUserOnly': onlineUserOnly,
|
||||
})) /*.then((value) => _toObj(value))*/;
|
||||
|
||||
/// Find all history message
|
||||
Future<List<Message>> getHistoryMessageList({
|
||||
@ -60,157 +59,139 @@ class MessageManager {
|
||||
String? groupID,
|
||||
Message? startMsg,
|
||||
int? count,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'getHistoryMessageList',
|
||||
_buildParam({
|
||||
'userID': userID ?? '',
|
||||
'startMsg': startMsg?.toJson() /*?? {}*/,
|
||||
'groupID': groupID ?? '',
|
||||
'count': count ?? 10,
|
||||
}))
|
||||
.then((value) => _toList(value));
|
||||
}
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'getHistoryMessageList',
|
||||
_buildParam({
|
||||
'userID': userID ?? '',
|
||||
'startMsg': startMsg?.toJson() /*?? {}*/,
|
||||
'groupID': groupID ?? '',
|
||||
'count': count ?? 10,
|
||||
}))
|
||||
.then((value) => _toList(value));
|
||||
|
||||
/// Revoke the sent information
|
||||
Future revokeMessage({required Message message}) {
|
||||
return _channel.invokeMethod(
|
||||
'revokeMessage', _buildParam(message.toJson()));
|
||||
}
|
||||
Future revokeMessage({required Message message}) =>
|
||||
_channel.invokeMethod('revokeMessage', _buildParam(message.toJson()));
|
||||
|
||||
/// Delete message
|
||||
Future deleteMessageFromLocalStorage({required Message message}) {
|
||||
return _channel.invokeMethod(
|
||||
'deleteMessageFromLocalStorage', _buildParam(message.toJson()));
|
||||
}
|
||||
Future deleteMessageFromLocalStorage({required Message message}) =>
|
||||
_channel.invokeMethod(
|
||||
'deleteMessageFromLocalStorage', _buildParam(message.toJson()));
|
||||
|
||||
///
|
||||
@deprecated
|
||||
Future deleteMessages({required List<Message> msgList}) {
|
||||
return _channel.invokeMethod('deleteMessages',
|
||||
_buildParam({"msgList": msgList.map((e) => e.toJson()).toList()}));
|
||||
}
|
||||
Future deleteMessages({required List<Message> msgList}) =>
|
||||
_channel.invokeMethod('deleteMessages',
|
||||
_buildParam({"msgList": msgList.map((e) => e.toJson()).toList()}));
|
||||
|
||||
///
|
||||
Future insertSingleMessageToLocalStorage({
|
||||
String? receiver,
|
||||
String? sender,
|
||||
Message? message,
|
||||
}) {
|
||||
return _channel.invokeMethod(
|
||||
'insertSingleMessageToLocalStorage',
|
||||
_buildParam({
|
||||
"userID": receiver,
|
||||
"message": message?.toJson(),
|
||||
"sender": sender,
|
||||
}));
|
||||
}
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'insertSingleMessageToLocalStorage',
|
||||
_buildParam({
|
||||
"userID": receiver,
|
||||
"message": message?.toJson(),
|
||||
"sender": sender,
|
||||
}));
|
||||
|
||||
/// Query the message according to the message id
|
||||
Future findMessages({required List<String> messageIDList}) {
|
||||
return _channel.invokeMethod(
|
||||
'findMessages',
|
||||
_buildParam({
|
||||
"messageIDList": messageIDList,
|
||||
}));
|
||||
}
|
||||
Future findMessages({required List<String> messageIDList}) =>
|
||||
_channel.invokeMethod(
|
||||
'findMessages',
|
||||
_buildParam({
|
||||
"messageIDList": messageIDList,
|
||||
}));
|
||||
|
||||
/// Mark c2c message as read
|
||||
Future markC2CMessageAsRead({
|
||||
required String userID,
|
||||
required List<String> messageIDList,
|
||||
}) {
|
||||
return _channel.invokeMethod(
|
||||
'markC2CMessageAsRead',
|
||||
_buildParam({
|
||||
"messageIDList": messageIDList,
|
||||
"userID": userID,
|
||||
}));
|
||||
}
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'markC2CMessageAsRead',
|
||||
_buildParam({
|
||||
"messageIDList": messageIDList,
|
||||
"userID": userID,
|
||||
}));
|
||||
|
||||
/// Typing
|
||||
Future typingStatusUpdate({
|
||||
required String userID,
|
||||
bool typing = false,
|
||||
}) {
|
||||
return _channel.invokeMethod(
|
||||
'typingStatusUpdate',
|
||||
_buildParam({
|
||||
"typing": typing ? 'yes' : 'no',
|
||||
"userID": userID,
|
||||
}));
|
||||
}
|
||||
}) =>
|
||||
_channel.invokeMethod(
|
||||
'typingStatusUpdate',
|
||||
_buildParam({
|
||||
"typing": typing ? 'yes' : 'no',
|
||||
"userID": userID,
|
||||
}));
|
||||
|
||||
/// Create text message
|
||||
Future<Message> createTextMessage({required String text}) {
|
||||
return _channel
|
||||
.invokeMethod('createTextMessage', _buildParam({'text': text}))
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
Future<Message> createTextMessage({required String text}) => _channel
|
||||
.invokeMethod('createTextMessage', _buildParam({'text': text}))
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
/// Create @ message
|
||||
Future<Message> createTextAtMessage({
|
||||
required String text,
|
||||
required List<String> atUidList,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'createTextAtMessage',
|
||||
_buildParam({
|
||||
'text': text,
|
||||
'atUserList': atUidList,
|
||||
}),
|
||||
)
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'createTextAtMessage',
|
||||
_buildParam({
|
||||
'text': text,
|
||||
'atUserList': atUidList,
|
||||
}),
|
||||
)
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
/// Create picture message
|
||||
Future<Message> createImageMessage({required String imagePath}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'createImageMessage',
|
||||
_buildParam({'imagePath': imagePath}),
|
||||
)
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
Future<Message> createImageMessage({required String imagePath}) => _channel
|
||||
.invokeMethod(
|
||||
'createImageMessage',
|
||||
_buildParam({'imagePath': imagePath}),
|
||||
)
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
/// Create picture message
|
||||
Future<Message> createImageMessageFromFullPath({required String imagePath}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'createImageMessageFromFullPath',
|
||||
_buildParam({'imagePath': imagePath}),
|
||||
)
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
|
||||
Future<Message> createImageMessageFromFullPath({required String imagePath}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'createImageMessageFromFullPath',
|
||||
_buildParam({'imagePath': imagePath}),
|
||||
)
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
/// Create sound message
|
||||
Future<Message> createSoundMessage({
|
||||
required String soundPath,
|
||||
required int duration,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'createSoundMessage',
|
||||
_buildParam({'soundPath': soundPath, "duration": duration}),
|
||||
)
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'createSoundMessage',
|
||||
_buildParam({'soundPath': soundPath, "duration": duration}),
|
||||
)
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
/// Create sound message
|
||||
Future<Message> createSoundMessageFromFullPath({
|
||||
required String soundPath,
|
||||
required int duration,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'createSoundMessageFromFullPath',
|
||||
_buildParam({'soundPath': soundPath, "duration": duration}),
|
||||
)
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'createSoundMessageFromFullPath',
|
||||
_buildParam({'soundPath': soundPath, "duration": duration}),
|
||||
)
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
/// Create video message
|
||||
Future<Message> createVideoMessage({
|
||||
@ -218,18 +199,17 @@ class MessageManager {
|
||||
required String videoType,
|
||||
required int duration,
|
||||
required String snapshotPath,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'createVideoMessage',
|
||||
_buildParam({
|
||||
'videoPath': videoPath,
|
||||
'videoType': videoType,
|
||||
'duration': duration,
|
||||
'snapshotPath': snapshotPath,
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'createVideoMessage',
|
||||
_buildParam({
|
||||
'videoPath': videoPath,
|
||||
'videoType': videoType,
|
||||
'duration': duration,
|
||||
'snapshotPath': snapshotPath,
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
/// Create video message
|
||||
Future<Message> createVideoMessageFromFullPath({
|
||||
@ -237,18 +217,17 @@ class MessageManager {
|
||||
required String videoType,
|
||||
required int duration,
|
||||
required String snapshotPath,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'createVideoMessageFromFullPath',
|
||||
_buildParam({
|
||||
'videoPath': videoPath,
|
||||
'videoType': videoType,
|
||||
'duration': duration,
|
||||
'snapshotPath': snapshotPath,
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'createVideoMessageFromFullPath',
|
||||
_buildParam({
|
||||
'videoPath': videoPath,
|
||||
'videoType': videoType,
|
||||
'duration': duration,
|
||||
'snapshotPath': snapshotPath,
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
/// Create file message
|
||||
Future<Message> createFileMessage({
|
||||
@ -269,33 +248,31 @@ class MessageManager {
|
||||
Future<Message> createFileMessageFromFullPath({
|
||||
required String filePath,
|
||||
required String fileName,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'createFileMessageFromFullPath',
|
||||
_buildParam({
|
||||
'filePath': filePath,
|
||||
'fileName': fileName,
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'createFileMessageFromFullPath',
|
||||
_buildParam({
|
||||
'filePath': filePath,
|
||||
'fileName': fileName,
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
/// Create merger message
|
||||
Future<Message> createMergerMessage({
|
||||
required List<Message> messageList,
|
||||
required String title,
|
||||
required List<String> summaryList,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'createMergerMessage',
|
||||
_buildParam({
|
||||
'messageList': messageList.map((e) => e.toJson()).toList(),
|
||||
'title': title,
|
||||
'summaryList': summaryList,
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'createMergerMessage',
|
||||
_buildParam({
|
||||
'messageList': messageList.map((e) => e.toJson()).toList(),
|
||||
'title': title,
|
||||
'summaryList': summaryList,
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
/// Create forward message
|
||||
Future<Message> createForwardMessage({required Message message}) {
|
||||
@ -313,79 +290,71 @@ class MessageManager {
|
||||
required double latitude,
|
||||
required double longitude,
|
||||
required String description,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'createLocationMessage',
|
||||
_buildParam({
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
'description': description,
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'createLocationMessage',
|
||||
_buildParam({
|
||||
'latitude': latitude,
|
||||
'longitude': longitude,
|
||||
'description': description,
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
/// Create custom message
|
||||
Future<Message> createCustomMessage({
|
||||
required String data,
|
||||
required String extension,
|
||||
required String description,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'createCustomMessage',
|
||||
_buildParam({
|
||||
'data': data,
|
||||
'extension': extension,
|
||||
'description': description,
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'createCustomMessage',
|
||||
_buildParam({
|
||||
'data': data,
|
||||
'extension': extension,
|
||||
'description': description,
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
/// Create quote message
|
||||
Future<Message> createQuoteMessage({
|
||||
required String text,
|
||||
required Message quoteMsg,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'createQuoteMessage',
|
||||
_buildParam({
|
||||
'quoteText': text,
|
||||
'quoteMessage': quoteMsg.toJson(),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'createQuoteMessage',
|
||||
_buildParam({
|
||||
'quoteText': text,
|
||||
'quoteMessage': quoteMsg.toJson(),
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
/// Create card message
|
||||
Future<Message> createCardMessage({
|
||||
required Map<String, dynamic> data,
|
||||
}) {
|
||||
return _channel
|
||||
.invokeMethod(
|
||||
'createCardMessage',
|
||||
_buildParam({
|
||||
'cardMessage': data,
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
}
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'createCardMessage',
|
||||
_buildParam({
|
||||
'cardMessage': data,
|
||||
}))
|
||||
.then((value) => _toObj(value));
|
||||
|
||||
///
|
||||
Future<dynamic> clearC2CHistoryMessage({required String uid}) {
|
||||
return _channel.invokeMethod(
|
||||
'clearC2CHistoryMessage', _buildParam({"userID": uid}));
|
||||
}
|
||||
Future<dynamic> clearC2CHistoryMessage({required String uid}) => _channel
|
||||
.invokeMethod('clearC2CHistoryMessage', _buildParam({"userID": uid}));
|
||||
|
||||
///
|
||||
Future<dynamic> clearGroupHistoryMessage({required String gid}) {
|
||||
return _channel.invokeMethod(
|
||||
'clearGroupHistoryMessage', _buildParam({"groupID": gid}));
|
||||
}
|
||||
Future<dynamic> clearGroupHistoryMessage({required String gid}) => _channel
|
||||
.invokeMethod('clearGroupHistoryMessage', _buildParam({"groupID": gid}));
|
||||
|
||||
///
|
||||
void forceSyncMsg() {
|
||||
_channel.invokeMethod('forceSyncMsg', _buildParam({}));
|
||||
}
|
||||
// void forceSyncMsg() {
|
||||
// _channel.invokeMethod('forceSyncMsg', _buildParam({}));
|
||||
// }
|
||||
|
||||
static Map _buildParam(Map param) {
|
||||
param["ManagerName"] = "messageManager";
|
||||
@ -397,9 +366,7 @@ class MessageManager {
|
||||
|
||||
static Message _toObj(String value) => Message.fromJson(_formatJson(value));
|
||||
|
||||
static dynamic _formatJson(value) {
|
||||
return jsonDecode(_printValue(value));
|
||||
}
|
||||
static dynamic _formatJson(value) => jsonDecode(_printValue(value));
|
||||
|
||||
static String _printValue(value) {
|
||||
return value;
|
||||
|
@ -87,4 +87,14 @@ class ConversationInfo {
|
||||
bool get isGroupChat => conversationType == ConversationType.group_chat;
|
||||
|
||||
bool get isTop => isPinned == 1;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is ConversationInfo &&
|
||||
runtimeType == other.runtimeType &&
|
||||
conversationID == other.conversationID;
|
||||
|
||||
@override
|
||||
int get hashCode => conversationID.hashCode;
|
||||
}
|
||||
|
@ -153,17 +153,14 @@ class Message {
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (other is Message) {
|
||||
return other._id == _id;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is Message &&
|
||||
runtimeType == other.runtimeType &&
|
||||
clientMsgID == other.clientMsgID;
|
||||
|
||||
@override
|
||||
int get hashCode => super.hashCode;
|
||||
|
||||
String? get _id => clientMsgID;
|
||||
int get hashCode => clientMsgID.hashCode;
|
||||
}
|
||||
|
||||
class PictureElem {
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: flutter_openim_sdk
|
||||
description: An instant messaging plug-in that supports Android and IOS. And the server is also all open source.
|
||||
version: 1.0.7
|
||||
version: 1.0.8
|
||||
homepage: https://www.rentsoft.cn
|
||||
repository: https://github.com/OpenIMSDK/Open-IM-SDK-Flutter
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user