聊天框架,利用环信服务,实现的单聊群聊功能,音乐分享,网页分享扩展

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

id<IEMMessageBody> messageBody = [bodies firstObject];
    chatContentModel.messageBody = messageBody;
    chatContentModel.contentType = type;
    
    //普通文本消息和依靠普通文本消息扩展出来的消息类型
    GJGCMessageExtendModel *extendModel = [[GJGCMessageExtendModel alloc]initWithDictionary:msgModel.ext];
    
    switch ([messageBody messageBodyType]) {
        case eMessageBodyType_Image:
        {
            chatContentModel.contentType = GJGCChatFriendContentTypeImage;
        }
            break;
        case eMessageBodyType_Text:
        {
            NSLog(@"解析扩展内容:%@",[extendModel contentDictionary]);
            
            //普通文本消息
            if (!extendModel.isExtendMessageContent) {
                
                chatContentModel.contentType = GJGCChatFriendContentTypeText;
                
                EMTextMessageBody *textMessageBody = (EMTextMessageBody *)messageBody;
                
                if (!GJCFNSCacheGetValue(textMessageBody.text)) {
                    [GJGCChatFriendCellStyle formateSimpleTextMessage:textMessageBody.text];
                }
                chatContentModel.originTextMessage = textMessageBody.text;
                
            }
            
            //扩展消息类型
            if (extendModel.isExtendMessageContent) {
                
                chatContentModel.contentType = extendModel.chatFriendContentType;
                
                //是否支持显示的扩展消息
                if (extendModel.isSupportDisplay) {
                    
                    //进一步解析消息内容
                    switch (extendModel.chatFriendContentType) {
                        case GJGCChatFriendContentTypeGif:
                        {
                            GJGCMessageExtendContentGIFModel *gifContent = (GJGCMessageExtendContentGIFModel *)extendModel.messageContent;
                            chatContentModel.gifLocalId = gifContent.emojiCode;
                        }
                            break;
                        case GJGCChatFriendContentTypeMusicShare:
                        {
                            GJGCMessageExtendMusicShareModel  *musicContent = (GJGCMessageExtendMusicShareModel *)extendModel.messageContent;
                            chatContentModel.musicSongId = musicContent.songId;
                            chatContentModel.musicSongName = musicContent.title;
                            chatContentModel.musicSongUrl = musicContent.songUrl;
                            chatContentModel.musicSongAuthor = musicContent.author;
                        }
                            break;
                        case GJGCChatFriendContentTypeWebPage:
                        {
                            GJGCMessageExtendContentWebPageModel *webPageContent = (GJGCMessageExtendContentWebPageModel *)extendModel.messageContent;
                            chatContentModel.webPageThumbImageData = [webPageContent.thumbImageBase64 base64DecodedData];
                            chatContentModel.webPageTitle = webPageContent.title;
                            chatContentModel.webPageSumary = webPageContent.sumary;
                            chatContentModel.webPageUrl = webPageContent.url;
                            
                        }
                            break;
                        default:
                            break;
                    }
                }
                
                //如果不支持,需要将消息显示成文本消息
                if (![extendModel isSupportDisplay]) {
                    
                    chatContentModel.contentType = GJGCChatFriendContentTypeText;
                    
                    EMTextMessageBody *textMessageBody = (EMTextMessageBody *)messageBody;
                    
                    if (!GJCFNSCacheGetValue(textMessageBody.text)) {
                        [GJGCChatFriendCellStyle formateSimpleTextMessage:textMessageBody.text];
                    }
                    chatContentModel.originTextMessage = textMessageBody.text;
                }
            }
        }
            break;
        case eMessageBodyType_Command:
        {
            
        }
            break;
        case eMessageBodyType_File:
        {
            
        }
            break;
        case eMessageBodyType_Location:
        {
            
        }
            break;
        case eMessageBodyType_Video:
        {
            
        }
            break;
        case eMessageBodyType_Voice:
        {
            chatContentModel.contentType = GJGCChatFriendContentTypeAudio;
            
            EMVoiceMessageBody *voiceMessageBody = (EMVoiceMessageBody *)messageBody;
            
            chatContentModel.audioModel.localStorePath = voiceMessageBody.localPath;
            chatContentModel.audioModel.duration = voiceMessageBody.duration;
            chatContentModel.audioDuration =  [GJGCChatFriendCellStyle formateAudioDuration:GJCFStringFromInt(chatContentModel.audioModel.duration)];
        }
            break;
        default:
            break;
    }
    type = chatContentModel.contentType;
    
    //解析用户信息
    chatContentModel.headUrl = extendModel.userInfo.headThumb;
    if (chatContentModel.talkType == GJGCChatFriendTalkTypeGroup) {
        chatContentModel.senderName = [GJGCChatFriendCellStyle formateGroupChatSenderName:extendModel.userInfo.nickName];
    }