@@ -90,7 +90,7 @@ - (void)resendMessage:(NSString *)messageID{
9090 }
9191 }
9292}
93-
93+ // 聊天界面历史记录
9494-(void )localSession : (NSInteger )index cerrentmessageId : (NSString *)currentMessageID success : (Success)succe err : (Errors)err {
9595 _index = index;
9696 [[NIMSDK sharedSDK ].conversationManager markAllMessagesReadInSession: _session];
@@ -320,6 +320,12 @@ -(NSMutableArray *)setTimeArr:(NSArray *)messageArr{
320320 [dic setObject: @" card" forKey: @" msgType" ];
321321 }
322322 break ;
323+ case CustomMessgeTypeCustom:// 自定义
324+ {
325+ [dic setObject: obj.dataDict forKey: @" extend" ];
326+ [dic setObject: @" custom" forKey: @" msgType" ];
327+ }
328+ break ;
323329 default :
324330 {
325331 [dic setObject: obj.dataDict forKey: @" extend" ];
@@ -418,16 +424,27 @@ -(void)sendTextMessage:( NSString *)path duration:( NSString *)duration width:
418424}
419425
420426// 发送自定义消息
421- -(void )sendCustomMessage : ( NSString *)attachment config : ( NSString *)config {
427+ -(void )sendCustomMessage : (NSDictionary *)dataDict {
428+ NSString *strW = [dataDict objectForKey: @" Width" ] ? [NSString stringWithFormat: @" %@ " ,[dataDict objectForKey: @" Width" ]] : @" 0" ;
429+ NSString *strH = [dataDict objectForKey: @" Height" ] ? [NSString stringWithFormat: @" %@ " ,[dataDict objectForKey: @" Height" ]] : @" 0" ;
430+ [dataDict setValue: strW forKey: @" Width" ];
431+ [dataDict setValue: strH forKey: @" Height" ];
432+ [self sendCustomMessage: CustomMessgeTypeCustom data: dataDict];
433+ }
434+
435+ // 发送自定义消息2
436+ -(void )sendCustomMessage : (NSInteger )custType data : (NSDictionary *)dataDict {
422437 NIMMessage *message;
423- NIMObject *obj = [NIMObject initNIMObject ];
424- obj.attachment =attachment;
425- message = [NIMMessageMaker msgWithCustom: obj andeSession: _session];
438+ DWCustomAttachment *obj = [[DWCustomAttachment alloc ]init];
439+ obj.custType = custType;
440+ obj.dataDict = dataDict;
441+ message = [NIMMessageMaker msgWithCustomAttachment: obj andeSession: _session];
426442 if ([self isFriendToSendMessage: message]) {
427443 [[NIMSDK sharedSDK ].chatManager sendMessage: message toSession: _session error: nil ];
428444 }
429445}
430446
447+
431448// 发送地理位置消息
432449-(void )sendLocationMessage : ( NSString *)latitude longitude : ( NSString *)longitude address : ( NSString *)address {
433450 NIMLocationObject *locaObj = [[NIMLocationObject alloc ]initWithLatitude:[latitude doubleValue ] longitude: [longitude doubleValue ] title: address];
@@ -437,17 +454,6 @@ -(void)sendLocationMessage:( NSString *)latitude longitude:( NSString *)longit
437454 [[NIMSDK sharedSDK ].chatManager sendMessage: message toSession: _session error: nil ];
438455 }
439456}
440- // 发送自定义消息2
441- -(void )sendCustomMessage : (NSInteger )custType data : (NSDictionary *)dataDict {
442- NIMMessage *message;
443- DWCustomAttachment *obj = [[DWCustomAttachment alloc ]init];
444- obj.custType = custType;
445- obj.dataDict = dataDict;
446- message = [NIMMessageMaker msgWithCustomAttachment: obj andeSession: _session];
447- if ([self isFriendToSendMessage: message]) {
448- [[NIMSDK sharedSDK ].chatManager sendMessage: message toSession: _session error: nil ];
449- }
450- }
451457
452458// 发送提醒消息
453459-(void )sendTipMessage : ( NSString *)content {
@@ -943,7 +949,6 @@ -(void)refrashMessage:(NIMMessage *)message From:(NSString *)from {
943949 [dic2 setObject: notiObj forKey: @" extend" ];
944950
945951 }else if (message.messageType == NIMMessageTypeCustom) {
946- // [dic setObject:@"custom" forKey:@"msgType"];
947952 NIMCustomObject *customObject = message.messageObject ;
948953 DWCustomAttachment *obj = customObject.attachment ;
949954 if (obj) {
@@ -992,6 +997,12 @@ -(void)refrashMessage:(NIMMessage *)message From:(NSString *)from {
992997 [dic2 setObject: @" card" forKey: @" msgType" ];
993998 }
994999 break ;
1000+ case CustomMessgeTypeCustom:// 自定义
1001+ {
1002+ [dic2 setObject: obj.dataDict forKey: @" extend" ];
1003+ [dic2 setObject: @" custom" forKey: @" msgType" ];
1004+ }
1005+ break ;
9951006 default :
9961007 {
9971008 [dic2 setObject: obj.dataDict forKey: @" extend" ];
0 commit comments