Add custom emoji message
This commit is contained in:
parent
80152e2314
commit
6c0676fbe5
@ -41,5 +41,5 @@ android {
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
implementation 'io.openim:client-sdk:2.0.5@aar'
|
||||
implementation 'io.openim:client-sdk:2.0.8@aar'
|
||||
}
|
@ -285,6 +285,13 @@ public class MessageManager extends BaseManager {
|
||||
));
|
||||
}
|
||||
|
||||
public void createFaceMessage(MethodCall methodCall, MethodChannel.Result result) {
|
||||
CommonUtil.runMainThreadReturn(result, Open_im_sdk.createFaceMessage(
|
||||
value(methodCall, "operationID"),
|
||||
int2long(methodCall, "index"),
|
||||
value(methodCall, "data")
|
||||
));
|
||||
}
|
||||
// public void forceSyncMsg(MethodCall methodCall, MethodChannel.Result result) {
|
||||
// Open_im_sdk.forceSyncMsg();
|
||||
// }
|
||||
|
@ -33,6 +33,7 @@ public class MessageManager: BaseServiceManager {
|
||||
self["createCustomMessage"] = createCustomMessage
|
||||
self["createQuoteMessage"] = createQuoteMessage
|
||||
self["createCardMessage"] = createCardMessage
|
||||
self["createFaceMessage"] = createFaceMessage
|
||||
// self["forceSyncMsg"] = forceSyncMsg
|
||||
self["clearC2CHistoryMessage"] = clearC2CHistoryMessage
|
||||
self["clearGroupHistoryMessage"] = clearGroupHistoryMessage
|
||||
@ -75,15 +76,15 @@ public class MessageManager: BaseServiceManager {
|
||||
// func findMessages(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
// Open_im_sdkFindMessages(BaseCallback(result: result), methodCall[jsonString: "messageIDList"])
|
||||
// }
|
||||
|
||||
|
||||
func markC2CMessageAsRead(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
Open_im_sdkMarkC2CMessageAsRead(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "userID"], methodCall[jsonString: "messageIDList"])
|
||||
}
|
||||
|
||||
|
||||
func typingStatusUpdate(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
Open_im_sdkTypingStatusUpdate(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "userID"], methodCall[string: "msgTip"])
|
||||
}
|
||||
|
||||
|
||||
func createTextMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
callBack(result, Open_im_sdkCreateTextMessage(methodCall[string: "operationID"], methodCall[string: "text"]))
|
||||
}
|
||||
@ -116,18 +117,18 @@ public class MessageManager: BaseServiceManager {
|
||||
|
||||
func createVideoMessageFromFullPath(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
let prama = Open_im_sdkCreateVideoMessageFromFullPath(methodCall[string: "operationID"], methodCall[string: "videoPath"], methodCall[string: "videoType"],
|
||||
methodCall[int64: "duration"], methodCall[string: "snapshotPath"])
|
||||
methodCall[int64: "duration"], methodCall[string: "snapshotPath"])
|
||||
callBack(result, prama)
|
||||
}
|
||||
|
||||
func createFileMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
callBack(result, Open_im_sdkCreateFileMessage(methodCall[string: "operationID"], methodCall[string: "filePath"], methodCall[string: "fileName"]))
|
||||
}
|
||||
|
||||
func createFileMessageFromFullPath(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
callBack(result, Open_im_sdkCreateFileMessageFromFullPath(methodCall[string: "operationID"], methodCall[string: "filePath"], methodCall[string: "fileName"]))
|
||||
}
|
||||
|
||||
|
||||
func createFileMessageFromFullPath(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
callBack(result, Open_im_sdkCreateFileMessageFromFullPath(methodCall[string: "operationID"], methodCall[string: "filePath"], methodCall[string: "fileName"]))
|
||||
}
|
||||
|
||||
func createMergerMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
let prama = Open_im_sdkCreateMergerMessage(methodCall[string: "operationID"], methodCall[jsonString: "messageList"], methodCall[string: "title"],
|
||||
methodCall[jsonString: "summaryList"])
|
||||
@ -158,35 +159,38 @@ public class MessageManager: BaseServiceManager {
|
||||
func createCardMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
callBack(result, Open_im_sdkCreateCardMessage(methodCall[string: "operationID"], methodCall[jsonString: "cardMessage"]))
|
||||
}
|
||||
|
||||
|
||||
func createFaceMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
callBack(result, Open_im_sdkCreateFaceMessage(methodCall[string: "operationID"], methodCall[int: "index"], methodCall[string: "data"]))
|
||||
}
|
||||
// func forceSyncMsg(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
// Open_im_sdkForceSyncMsg()
|
||||
// callBack(result)
|
||||
// }
|
||||
|
||||
|
||||
func clearC2CHistoryMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
Open_im_sdkClearC2CHistoryMessage(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "userID"])
|
||||
}
|
||||
|
||||
|
||||
func clearGroupHistoryMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
|
||||
Open_im_sdkClearGroupHistoryMessage(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "groupID"])
|
||||
}
|
||||
|
||||
|
||||
public class SendMsgProgressListener: NSObject, Open_im_sdk_callbackSendMsgCallBackProtocol {
|
||||
private let channel: FlutterMethodChannel
|
||||
private let result: FlutterResult
|
||||
private let call: FlutterMethodCall
|
||||
|
||||
|
||||
init(channel: FlutterMethodChannel, result: @escaping FlutterResult, methodCall: FlutterMethodCall) {
|
||||
self.channel = channel
|
||||
self.result = result
|
||||
self.call = methodCall
|
||||
}
|
||||
|
||||
|
||||
public func onError(_ errCode: Int32, errMsg: String?) {
|
||||
DispatchQueue.main.async { self.result(FlutterError(code: "\(errCode)", message: errMsg, details: nil)) }
|
||||
}
|
||||
|
||||
|
||||
public func onProgress(_ progress: Int) {
|
||||
var values: [String: Any] = [:]
|
||||
let message = call[dict: "message"]
|
||||
@ -194,36 +198,36 @@ public class MessageManager: BaseServiceManager {
|
||||
values["progress"] = progress
|
||||
CommonUtil.emitEvent(channel: channel, method: "msgSendProgressListener", type: "onProgress", errCode: nil, errMsg: nil, data: values)
|
||||
}
|
||||
|
||||
|
||||
public func onSuccess(_ data: String?) {
|
||||
DispatchQueue.main.async { self.result(data) }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class AdvancedMsgListener: NSObject, Open_im_sdk_callbackOnAdvancedMsgListenerProtocol {
|
||||
private let channel: FlutterMethodChannel
|
||||
private let id: String
|
||||
|
||||
|
||||
init(channel: FlutterMethodChannel, id: String) {
|
||||
self.channel = channel
|
||||
self.id = id
|
||||
}
|
||||
|
||||
|
||||
public func onRecvC2CReadReceipt(_ msgReceiptList: String?) {
|
||||
var values: [String: Any] = [:]
|
||||
values["id"] = id
|
||||
values["haveReadMessage"] = msgReceiptList
|
||||
CommonUtil.emitEvent(channel: channel, method: "advancedMsgListener", type: "onRecvC2CReadReceipt", errCode: nil, errMsg: nil, data: values)
|
||||
}
|
||||
|
||||
|
||||
public func onRecvMessageRevoked(_ msgId: String?) {
|
||||
var values: [String: Any] = [:]
|
||||
values["id"] = id
|
||||
values["revokedMessage"] = msgId
|
||||
CommonUtil.emitEvent(channel: channel, method: "advancedMsgListener", type: "onRecvMessageRevoked", errCode: nil, errMsg: nil, data: values)
|
||||
}
|
||||
|
||||
|
||||
public func onRecvNewMessage(_ message: String?) {
|
||||
var values: [String: Any] = [:]
|
||||
values["id"] = id
|
||||
|
@ -29,6 +29,9 @@ FOUNDATION_EXPORT void Open_im_sdkAddFriend(id<Open_im_sdk_callbackBase> _Nullab
|
||||
|
||||
FOUNDATION_EXPORT void Open_im_sdkCheckFriend(id<Open_im_sdk_callbackBase> _Nullable callback, NSString* _Nullable operationID, NSString* _Nullable userIDList);
|
||||
|
||||
// skipped function CheckResourceLoad with unsupported parameter or return types
|
||||
|
||||
|
||||
FOUNDATION_EXPORT BOOL Open_im_sdkCheckToken(NSString* _Nullable userID, NSString* _Nullable token, NSError* _Nullable* _Nullable error);
|
||||
|
||||
FOUNDATION_EXPORT void Open_im_sdkClearC2CHistoryMessage(id<Open_im_sdk_callbackBase> _Nullable callback, NSString* _Nullable operationID, NSString* _Nullable userID);
|
||||
@ -39,6 +42,8 @@ FOUNDATION_EXPORT NSString* _Nonnull Open_im_sdkCreateCardMessage(NSString* _Nul
|
||||
|
||||
FOUNDATION_EXPORT NSString* _Nonnull Open_im_sdkCreateCustomMessage(NSString* _Nullable operationID, NSString* _Nullable data, NSString* _Nullable extension, NSString* _Nullable description);
|
||||
|
||||
FOUNDATION_EXPORT NSString* _Nonnull Open_im_sdkCreateFaceMessage(NSString* _Nullable operationID, long index, NSString* _Nullable data);
|
||||
|
||||
FOUNDATION_EXPORT NSString* _Nonnull Open_im_sdkCreateFileMessage(NSString* _Nullable operationID, NSString* _Nullable filePath, NSString* _Nullable fileName);
|
||||
|
||||
FOUNDATION_EXPORT NSString* _Nonnull Open_im_sdkCreateFileMessageByURL(NSString* _Nullable operationID, NSString* _Nullable fileBaseInfo);
|
||||
|
Binary file not shown.
@ -7,6 +7,7 @@ class MessageType {
|
||||
static const file = 105;
|
||||
static const at_text = 106;
|
||||
static const merger = 107;
|
||||
|
||||
// static const forward = 108;
|
||||
static const card = 108;
|
||||
static const location = 109;
|
||||
@ -15,6 +16,7 @@ class MessageType {
|
||||
static const has_read_receipt = 112;
|
||||
static const typing = 113;
|
||||
static const quote = 114;
|
||||
static const custom_face = 115;
|
||||
|
||||
///
|
||||
static const accept_friend = 201;
|
||||
|
@ -444,6 +444,25 @@ class MessageManager {
|
||||
}))
|
||||
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
|
||||
|
||||
/// Create custom emoji message
|
||||
/// 创建自定义表情消息
|
||||
/// [index] The position of the emoji, such as the position emoji(表情的位置,如位置表情)
|
||||
/// [data] Other data, such as url expressions(其他数据,如url表情)
|
||||
Future<Message> createFaceMessage({
|
||||
int index = -1,
|
||||
String? data,
|
||||
String? operationID,
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'createFaceMessage',
|
||||
_buildParam({
|
||||
'index': index,
|
||||
'data': data,
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
|
||||
|
||||
/// Clear all c2c history message
|
||||
/// 清空单聊消息记录
|
||||
Future<dynamic> clearC2CHistoryMessage({
|
||||
|
@ -36,6 +36,7 @@ class Message {
|
||||
QuoteElem? quoteElem;
|
||||
MergeElem? mergeElem;
|
||||
NotificationElem? notificationElem;
|
||||
FaceElem? faceElem;
|
||||
|
||||
Message({
|
||||
this.clientMsgID,
|
||||
@ -69,6 +70,7 @@ class Message {
|
||||
this.quoteElem,
|
||||
this.mergeElem,
|
||||
this.notificationElem,
|
||||
this.faceElem,
|
||||
});
|
||||
|
||||
Message.fromJson(Map<String, dynamic> json) {
|
||||
@ -123,6 +125,8 @@ class Message {
|
||||
notificationElem = json['notificationElem'] != null
|
||||
? NotificationElem.fromJson(json['notificationElem'])
|
||||
: null;
|
||||
faceElem =
|
||||
json['faceElem'] != null ? FaceElem.fromJson(json['faceElem']) : null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@ -158,6 +162,7 @@ class Message {
|
||||
data['quoteElem'] = this.quoteElem?.toJson();
|
||||
data['mergeElem'] = this.mergeElem?.toJson();
|
||||
data['notificationElem'] = this.notificationElem?.toJson();
|
||||
data['faceElem'] = this.faceElem?.toJson();
|
||||
return data;
|
||||
}
|
||||
|
||||
@ -172,8 +177,7 @@ class Message {
|
||||
int get hashCode => clientMsgID.hashCode;
|
||||
|
||||
void update(Message message) {
|
||||
if (clientMsgID != message.clientMsgID) return;
|
||||
// clientMsgID = message.clientMsgID;
|
||||
if (this != message) return;
|
||||
serverMsgID = message.serverMsgID;
|
||||
createTime = message.createTime;
|
||||
sendTime = message.sendTime;
|
||||
@ -204,6 +208,7 @@ class Message {
|
||||
quoteElem = message.quoteElem;
|
||||
mergeElem = message.mergeElem;
|
||||
notificationElem = message.notificationElem;
|
||||
faceElem = message.faceElem;
|
||||
}
|
||||
}
|
||||
|
||||
@ -548,6 +553,25 @@ class NotificationElem {
|
||||
}
|
||||
}
|
||||
|
||||
class FaceElem {
|
||||
int? index;
|
||||
String? data;
|
||||
|
||||
FaceElem({this.index, this.data});
|
||||
|
||||
FaceElem.fromJson(Map<String, dynamic> json) {
|
||||
index = json['index'];
|
||||
data = json['data'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = Map<String, dynamic>();
|
||||
data['index'] = this.index;
|
||||
data['data'] = this.data;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class ReadReceiptInfo {
|
||||
String? uid;
|
||||
List<String>? msgIDList;
|
||||
|
@ -16,11 +16,17 @@ class UserInfo {
|
||||
int? createTime;
|
||||
String? remark;
|
||||
|
||||
/// User's public profile(用户公开的资料)
|
||||
PublicUserInfo? publicInfo;
|
||||
|
||||
/// Only friends can view information(好友才能查看的资料)
|
||||
FriendInfo? friendInfo;
|
||||
|
||||
/// blacklist information(黑名单资料)
|
||||
BlacklistInfo? blackInfo;
|
||||
|
||||
bool? isFriendship;
|
||||
|
||||
bool? isBlacklist;
|
||||
|
||||
UserInfo({
|
||||
@ -76,7 +82,7 @@ class UserInfo {
|
||||
birth = json['birth'] ?? _birth;
|
||||
email = json['email'] ?? _email;
|
||||
remark = json['remark'] ?? _remark;
|
||||
ex = json['ex'];
|
||||
ex = json['ex'] ?? _ex;
|
||||
createTime = json['createTime'];
|
||||
}
|
||||
|
||||
@ -123,6 +129,10 @@ class UserInfo {
|
||||
? friendInfo?.gender
|
||||
: (isBlacklist! ? blackInfo?.gender : publicInfo?.gender);
|
||||
|
||||
String? get _ex => isFriendship!
|
||||
? friendInfo?.ex
|
||||
: (isBlacklist! ? blackInfo?.ex : publicInfo?.ex);
|
||||
|
||||
String? get _phoneNumber => friendInfo?.phoneNumber;
|
||||
|
||||
int? get _birth => friendInfo?.birth;
|
||||
@ -131,9 +141,9 @@ class UserInfo {
|
||||
|
||||
String? get _remark => friendInfo?.remark;
|
||||
|
||||
String getShowName() => _trimBlank(remark) ?? _trimBlank(nickname) ?? userID!;
|
||||
String getShowName() => _isNull(remark) ?? _isNull(nickname) ?? userID!;
|
||||
|
||||
static String? _trimBlank(String? value) {
|
||||
static String? _isNull(String? value) {
|
||||
if (value == null || value.trim().isEmpty) return null;
|
||||
return value;
|
||||
}
|
||||
@ -145,6 +155,7 @@ class PublicUserInfo {
|
||||
String? faceURL;
|
||||
int? gender;
|
||||
int? appMangerLevel;
|
||||
String? ex;
|
||||
|
||||
PublicUserInfo({
|
||||
this.userID,
|
||||
@ -152,6 +163,7 @@ class PublicUserInfo {
|
||||
this.faceURL,
|
||||
this.gender,
|
||||
this.appMangerLevel,
|
||||
this.ex,
|
||||
});
|
||||
|
||||
PublicUserInfo.fromJson(Map<String, dynamic> json) {
|
||||
@ -160,6 +172,7 @@ class PublicUserInfo {
|
||||
faceURL = json['faceURL'];
|
||||
gender = json['gender'];
|
||||
appMangerLevel = json['appMangerLevel'];
|
||||
ex = json['ex'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@ -169,6 +182,7 @@ class PublicUserInfo {
|
||||
data['faceURL'] = this.faceURL;
|
||||
data['gender'] = this.gender;
|
||||
data['appMangerLevel'] = this.appMangerLevel;
|
||||
data['ex'] = this.ex;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user