菜鸟搞环信
剛完成了環信的相關工作,剛好有時間來寫一下關于環信的東西
馬上進入主題吧
?
1.關于如何集成環信。
集成環信的話就不多說了
2.如何修改環信的昵稱和頭像。
這個我認為是重點。我也是一個新手,都是一步一個腳印,慢慢踩踏過來的。
我的做法是分兩個,一個是利用環信的ext擴展作為突破口。第二個是利用本地緩存作為突破口。
首先說一下,為什么有兩個?
因為,我們在發消息的時候,可以利用環信的ext擴展,把頭像之類的東西,存到消息里面。這樣,我們在發消息的時候就可以獲得頭像之類的東西,然后就可以更新chatview。這個僅僅作用于發消息。在我們接收到一條新消息的時候,就不能這么搞了。因為,如果你之前沒有發送過消息給他,那么你的ext擴展就不能穿過去給他。這樣就會造成只有你發過消息的人才能正常顯示。這里就需要用到本地緩存了。
大致的思路就這樣,那么我們就分散一步一步來~~
?
A。首先把單聊發消息的這個給先實現。
從這里push到環信的會話列表。push之前安全起見,先本地化頭像。。
- (void)pushToChatViewController{
? ? /// 新建一個會話
? ? if ([self.model.user_no isEqualToString:[UserInfo shareUserInfo].user_no]) {
? ? ? ? [MBProgressHUD showAndDismissInWindow:@"不能與自己聊天"];
? ? ? ? return;
? ? }
? ? NSString *name = self.model.user_niname;
? ? if (name.length == 0 || [name isEqualToString:@""]) {
? ? ? ? name = @"xx";
? ? }
? ? //TODO:這里我只是為了測試
? ? NSString *img = self.model.user_headimg;
? ? if (img.length == 0 || [img isEqualToString:@""]) {
? ? ? ? img = @"";
? ? }
?? ?
? ? //保存用戶的昵稱和頭像到數據庫
? ? MCNickNameDB *nickNameDB = [MCNickNameDB findFirstByCriteria:[NSString stringWithFormat:@" WHERE conversationId = %@ ",name]];
? ? if (nickNameDB) {
? ? ? ? MCNickNameDB *n = [MCNickNameDB new];
? ? ? ? n.conversationId = self.userId;
? ? ? ? n.niname = name;
? ? ? ? n.headimg = img;
? ? ? ? BOOL nick = [nickNameDB.niname isEqualToString:n.niname];
? ? ? ? BOOL img = [nickNameDB.headimg isEqualToString:n.headimg];
? ? ? ? if (!nick || !img) {
? ? ? ? ? ? [MCNickNameDB deleteObjectsByCriteria:[NSString stringWithFormat:@" WHERE conversationId = %@ ",n.conversationId]];
? ? ? ? ? ? [n save];
? ? ? ? ? ? MCNickNameDB *nickNameDB2 = [MCNickNameDB findFirstByCriteria:[NSString stringWithFormat:@" WHERE conversationId = %@ ",n.conversationId]];
? ? ? ? ? ? DLog(@"%@",nickNameDB2);
? ? ? ? }
?? ? ? ?
? ? }else{
? ? ? ? MCNickNameDB *n = [MCNickNameDB new];
? ? ? ? n.conversationId = self.userId;
? ? ? ? n.niname = name;
? ? ? ? n.headimg = img;
? ? ? ? [n save];
? ? }
?? ?
? ? NSDictionary *ext = @{
? ? ? ? ? ? ? ? ? ? ? ? ? EASE_Nicname_Other_Key:name,
? ? ? ? ? ? ? ? ? ? ? ? ? EASE_Avatar_Other_Key:img
? ? ? ? ? ? ? ? ? ? ? ? ? };
? ? ChatViewController *chatController = [[ChatViewController alloc] initWithConversationChatter:_userId conversationType:EMConversationTypeChat ext:ext];
? ? DLog(@"新建一個會話 ext == %@ ",ext);
? ? chatController.title = _model.user_niname;
? ? [self.navigationController pushViewController:chatController animated:YES];
}
既然是發消息,那么久肯定跟EaseChatToolbar輸入框有關了
找到EaseChatToolbar ?
- (void)sendFaceWithEmotion:(EaseEmotion *)emotion{
if (emotion) {
? ? ? ? if ([self.delegate respondsToSelector:@selector(didSendText:withExt:)]) {
? ? ? ? ? ? NSString *name = EASE_Nik_Name_Value;
? ? ? ? ? ? NSString *img = EASE_Avatar_Value;
? ? ? ? ? ? if ([name isEqualToString:@""] || name.length == 0) {
? ? ? ? ? ? ? ? ?name = EASE_Nik_Name_Def;
? ? ? ? ? ? }
? ? ? ? ? ? if ([img isEqualToString:@""] || img.length == 0) {
? ? ? ? ? ? ? ? img = EASE_Avatar_Def;
? ? ? ? ? ? }
? ? ? ? ? ? /// ?兔斯基表情文本擴展
? ? ? ? ? ? NSDictionary *ext = @{
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? EASEUI_EMOTION_DEFAULT_EXT:emotion,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? EASE_Avatar_Key:img,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? EASE_Nik_Name_Key:name
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? };
? ? ? ? ? ? [self.delegate didSendText:emotion.emotionTitle withExt:ext];
? ? ? ? ? ? [self _willShowInputTextViewToHeight:[self _getTextViewContentH:self.inputTextView]];;
? ? ? ? }
? ? }
?
}
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
if ([text isEqualToString:@"\n"]) {
? ? ? ? if ([self.delegate respondsToSelector:@selector(didSendText:)]) {
? ? ? ? ? ? NSString *name = EASE_Nik_Name_Value;
? ? ? ? ? ? NSString *img = EASE_Avatar_Value;
? ? ? ? ? ? if ([name isEqualToString:@""] || name.length == 0) {
? ? ? ? ? ? ? ? name = EASE_Nik_Name_Def;
? ? ? ? ? ? }
? ? ? ? ? ? if ([img isEqualToString:@""] || img.length == 0) {
? ? ? ? ? ? ? ? img = EASE_Avatar_Def;
? ? ? ? ? ? }
? ? ? ? ? ?NSDictionary *ext = @{
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? EASE_Avatar_Key:img,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? EASE_Nik_Name_Key:name
?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? };
? ? ? ? ? ? [self.delegate didSendText:textView.text withExt:ext];
? ? ? ? ? ? //結束
? ? ? ? ? ? self.inputTextView.text = @"";
? ? ? ? ? ? [self _willShowInputTextViewToHeight:[self _getTextViewContentH:self.inputTextView]];
? ? ? ? }
? ? ? ? return NO;
? ? }
? ? else if ([text isEqualToString:@"@"]) {
? ? ? ? if ([self.delegate respondsToSelector:@selector(didInputAtInLocation:)]) {
? ? ? ? ? ? if ([self.delegate didInputAtInLocation:range.location]) {
? ? ? ? ? ? ? ? [self _willShowInputTextViewToHeight:[self _getTextViewContentH:self.inputTextView]];
? ? ? ? ? ? ? ? return NO;
? ? ? ? ? ? }
? ? ? ? }
? ? }
? ? else if ([text length] == 0) {
? ? ? ? //delete one character
? ? ? ? if (range.length == 1 && [self.delegate respondsToSelector:@selector(didDeleteCharacterFromLocation:)]) {
? ? ? ? ? ? return ![self.delegate didDeleteCharacterFromLocation:range.location];
? ? ? ? }
? ? }
? ? return YES;
?
}
在這兩個方法上面 ,添加ext。。其實細心的人可以發現EaseChatToolbar的delegate是EaseMessageViewController
所以也可以
我比較建議在EaseMessageViewController,因為不管什么類型的消息都是走這個類的
?
代碼如下
- (void)didSendText:(NSString *)text withExt:(NSDictionary*)ext
{
? ? //TODO:這里是不包括 add的?
? ? DLog(@"消息的攜帶體是ext == %@",ext);
? ? DLog(@"img == %@, name == %@",ext[EASE_Avatar_Key],ext[EASE_Nik_Name_Def]);
? ? NSMutableDictionary *dic = [NSMutableDictionary dictionary];
? ? dic[EASE_Avatar_Key] = ext[EASE_Avatar_Key];
? ? dic[EASE_Nik_Name_Def] = ext[EASE_Nik_Name_Def];
? ? DLog(@"conversation == %@",_conversation.conversationId);
? ? if (self.conversation.type == 1) {/// 群聊
? ? ? ? MCNickNameDB *nickNameDB = [MCNickNameDB findFirstByCriteria:[NSString stringWithFormat:@" WHERE conversationId = %@ ",_conversation.conversationId]];
? ? ? ? dic[EASE_GroupID__Key] = nickNameDB.conversationId;
? ? ? ? dic[EASE_Nicname_Group_Key] = nickNameDB.niname;
? ? ? ? dic[EASE_Avatar_Group_Key] = nickNameDB.headimg;
? ? ? ? DLog(@"EASE_GroupID__Key == %@",dic[EASE_Nicname_Group_Key]);
? ? }
?? ?
?? ?
? ? if ([ext objectForKey:EASEUI_EMOTION_DEFAULT_EXT]) {
? ? ? ? EaseEmotion *emotion = [ext objectForKey:EASEUI_EMOTION_DEFAULT_EXT];
? ? ? ? if (self.dataSource && [self.dataSource respondsToSelector:@selector(emotionExtFormessageViewController:easeEmotion:)]) {
? ? ? ? ? ? /// 這里是純兔斯基 發送 ?
? ? ? ? ? ? NSDictionary *emojiDic = [self.dataSource emotionExtFormessageViewController:self easeEmotion:emotion];
? ? ? ? ? ? if (self.conversation.type == 1) {/// 群聊
? ? ? ? ? ? ? ? dic[@"em_expression_id"] = emojiDic[@"em_expression_id"];
? ? ? ? ? ? ? ? dic[@"em_is_big_expression"] = emojiDic[@"em_is_big_expression"];
? ? ? ? ? ? }
?? ? ? ? ? ?
? ? ? ? ? ? [self sendTextMessage:emotion.emotionTitle withExt:dic];
? ? ? ? } else {
? ? ? ? ? ? // 這里需要加上消息擴張
? ? ? ? ? ? if (self.conversation.type == 0) {
? ? ? ? ? ? ? ? [self sendTextMessage:emotion.emotionTitle withExt:
?? ? ? ? ? ? ? ? @{
?? ? ? ? ? ? ? ? ? MESSAGE_ATTR_EXPRESSION_ID:emotion.emotionId,MESSAGE_ATTR_IS_BIG_EXPRESSION:@(YES),
?? ? ? ? ? ? ? ? ? EASE_Avatar_Key:dic[EASE_Avatar_Key],
?? ? ? ? ? ? ? ? ? EASE_Nik_Name_Key:dic[EASE_Nik_Name_Key]
?? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ?
?? ? ? ? ? ? ? ? ];
? ? ? ? ? ? }else{/// 群聊
? ? ? ? ? ? ? ? [self sendTextMessage:emotion.emotionTitle withExt:
?? ? ? ? ? ? ? ? @{
?? ? ? ? ? ? ? ? ? MESSAGE_ATTR_EXPRESSION_ID:emotion.emotionId,MESSAGE_ATTR_IS_BIG_EXPRESSION:@(YES),
?? ? ? ? ? ? ? ? ? EASE_Avatar_Key:dic[EASE_Avatar_Key],
?? ? ? ? ? ? ? ? ? EASE_Nik_Name_Key:dic[EASE_Nik_Name_Key],
?? ? ? ? ? ? ? ? ? EASE_Avatar_Group_Key:dic[EASE_Avatar_Group_Key],
?? ? ? ? ? ? ? ? ? EASE_Nicname_Group_Key:dic[EASE_Nicname_Group_Key],
?? ? ? ? ? ? ? ? ? EASE_GroupID__Key:dic[EASE_GroupID__Key]
?? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ?
?? ? ? ? ? ? ? ? ];
? ? ? ? ? ? }
?? ? ? ? ? ?
? ? ? ? }
? ? ? ? return;
? ? }
? ? if (text && text.length > 0) {
? ? ? ? /// 純文字副本發送 ? ?
? ? ? ? if (self.conversation.type == 0) {?
? ? ? ? ? ? [self sendTextMessage:text withExt:ext];
? ? ? ? }else{/// 群聊
? ? ? ? ? ? [self sendTextMessage:text withExt:dic];
? ? ? ? }
?? ? ? ?
? ? }
}
?
以上標有群聊的可以先忽略不做
在所有發消息的(兔斯基,表情,文字,表情+文字等等)統統加上ext
例如
- (void)sendTextMessage:(NSString *)text
{
? ? // NSDictionary *ext = nil;
? ? /// 在這里添加emoji 頭像?
? ? NSString *name = EASE_Nik_Name_Value;
? ? NSString *img = EASE_Avatar_Value;
? ? if ([name isEqualToString:@""] || name.length == 0) {
? ? ? ? name = EASE_Nik_Name_Def;
? ? }
? ? if ([img isEqualToString:@""] || img.length == 0) {
? ? ? ? img = EASE_Avatar_Def;
? ? }
?? ?
? ? NSMutableDictionary *ext = [NSMutableDictionary dictionary];
? ? ext[EASE_Avatar_Key] = img;
? ? ext[EASE_Nik_Name_Key] = name;
?? ?
? ? if (self.conversation.type == 1) {//群聊
? ? ? ? MCNickNameDB *nickNameDB = [MCNickNameDB findFirstByCriteria:[NSString stringWithFormat:@" WHERE conversationId = %@ ",_conversation.conversationId]];
? ? ? ? ext[EASE_GroupID__Key] = nickNameDB.conversationId;
? ? ? ? ext[EASE_Nicname_Group_Key] = nickNameDB.niname;
? ? ? ? ext[EASE_Avatar_Group_Key] = nickNameDB.headimg;
? ? ? ? DLog(@"EASE_GroupID__Key == %@",ext[EASE_Nicname_Group_Key]);
? ? }
? ? if (self.conversation.type == EMConversationTypeGroupChat) {
? ? ? ? NSArray *targets = [self _searchAtTargets:text];
? ? ? ? if ([targets count]) {
? ? ? ? ? ? __block BOOL atAll = NO;
? ? ? ? ? ? [targets enumerateObjectsUsingBlock:^(NSString *target, NSUInteger idx, BOOL *stop) {
? ? ? ? ? ? ? ? if ([target compare:kGroupMessageAtAll options:NSCaseInsensitiveSearch] == NSOrderedSame) {
? ? ? ? ? ? ? ? ? ? atAll = YES;
? ? ? ? ? ? ? ? ? ? *stop = YES;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }];
? ? ? ? ? ? if (atAll) {
? ? ? ? ? ? ? ? ext = @{kGroupMessageAtList: kGroupMessageAtAll};
? ? ? ? ? ? }
? ? ? ? ? ? else {
? ? ? ? ? ? ? ? ext = @{kGroupMessageAtList: targets};
? ? ? ? ? ? }
? ? ? ? }
? ? }
? ? [self sendTextMessage:text withExt:ext];
}
?
那么,所有的消息都帶上了ext,基本上發消息的就完成了。
回到chatViewController里面
- (NSDictionary*)emotionExtFormessageViewController:(EaseMessageViewController *)viewController
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? easeEmotion:(EaseEmotion*)easeEmotion{
? ? /// ?兔斯基表情文本擴展
? ? NSString *name = EASE_Nik_Name_Value;
? ? NSString *img = EASE_Avatar_Value;
? ? if ([name isEqualToString:@""] || name.length == 0) {
? ? ? ? name = EASE_Nik_Name_Def;
? ? }
? ? if ([img isEqualToString:@""] || img.length == 0) {
? ? ? ? img = EASE_Avatar_Def;
? ? }
? ? return @{
?? ? ? ? ? ? MESSAGE_ATTR_EXPRESSION_ID:easeEmotion.emotionId,MESSAGE_ATTR_IS_BIG_EXPRESSION:@(YES),
?? ? ? ? ? ? EASE_Avatar_Key:img,
?? ? ? ? ? ? EASE_Nik_Name_Key:name
?? ? ? ? ? ? };
}
?
- (id<IMessageModel>)messageViewController:(EaseMessageViewController *)viewController
?? ? ? ? ? ? ? ? ? ? ? ? ? modelForMessage:(EMMessage *)message{
? ? id<IMessageModel> model = nil;
? ? model = [[EaseMessageModel alloc] initWithMessage:message];
? ? //TODO:這里設置環信的頭像
? ? NSDictionary *dic? = message.ext;
? ? NSString *userName = dic[EASE_Nik_Name_Key];
? ? NSString *sendUserImg = dic[EASE_Avatar_Key];
? ? model.avatarURLPath = sendUserImg;
? ? model.nickname = userName;
? ? UserProfileEntity *profileEntity = [[UserProfileManager sharedInstance] getUserProfileByUsername:model.nickname];
? ? if (profileEntity) {
? ? ? ? model.avatarURLPath = profileEntity.imageUrl;
? ? ? ? model.nickname = profileEntity.nickname;
? ? }
? ? model.failImageName = @"imageDownloadFail";
? ? return model;
}
?
這樣發消息就ok了。。。
下面就說一下接收消息,接收消息我用本地緩存。
接收消息的話,就找chatdemohelper
找到
/// 這里好重要 ? 就是收到消息擴張?
- (void)didReceiveMessages:(NSArray *)aMessages
{
? ? //保存用戶的昵稱和頭像到數據庫
? ? BOOL isRefreshCons = YES;
? ? for(EMMessage *message in aMessages){
?? ? ? ?
? ? ? ? DLog(@"EMChatType == %d? ext == %@",message.chatType,message.ext);
?? ? ? ?
? ? ? ? if (message.chatType == 0) { // 單聊
? ? ? ? ? ? //保存用戶的昵稱和頭像到數據庫
? ? ? ? ? ? MCNickNameDB *nickNameDB = [MCNickNameDB findFirstByCriteria:[NSString stringWithFormat:@" WHERE conversationId = %@ ",message.conversationId]];
? ? ? ? ? ? if (nickNameDB) {
? ? ? ? ? ? ? ? MCNickNameDB *n = [MCNickNameDB new];
? ? ? ? ? ? ? ? n.conversationId = message.conversationId;
? ? ? ? ? ? ? ? n.niname = message.ext[EASE_Nik_Name_Key];
? ? ? ? ? ? ? ? n.headimg = message.ext[EASE_Avatar_Key];
? ? ? ? ? ? ? ? BOOL nick = [nickNameDB.niname isEqualToString:n.niname];
? ? ? ? ? ? ? ? BOOL img = [nickNameDB.headimg isEqualToString:n.headimg];
? ? ? ? ? ? ? ? if (!nick || !img) {
? ? ? ? ? ? ? ? ? ? [MCNickNameDB deleteObjectsByCriteria:[NSString stringWithFormat:@" WHERE conversationId = %@ ",message.conversationId]];
? ? ? ? ? ? ? ? ? ? [n save];
? ? ? ? ? ? ? ? ? ? MCNickNameDB *nickNameDB2 = [MCNickNameDB findFirstByCriteria:[NSString stringWithFormat:@" WHERE conversationId = %@ ",message.conversationId]];
? ? ? ? ? ? ? ? ? ? DLog(@"%@",nickNameDB2);
? ? ? ? ? ? ? ? }
?? ? ? ? ? ? ? ?
? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? MCNickNameDB *n = [MCNickNameDB new];
? ? ? ? ? ? ? ? n.conversationId = message.conversationId;
? ? ? ? ? ? ? ? n.niname = message.ext[EASE_Nik_Name_Key];
? ? ? ? ? ? ? ? n.headimg = message.ext[EASE_Avatar_Key];
? ? ? ? ? ? ? ? [n save];
? ? ? ? ? ? }
? ? ? ? }else{ //TODO: 聊天時 群聊
? ? ? ? ? ? //保存群聊的昵稱和頭像到數據庫
? ? ? ? ? ? NSDictionary *ext = message.ext;
? ? ? ? ? ? MCNickNameDB *nickNameDB = [MCNickNameDB findFirstByCriteria:[NSString stringWithFormat:@" WHERE conversationId = %@ ",message.conversationId]];
? ? ? ? ? ? if (nickNameDB) {
? ? ? ? ? ? ? ? MCNickNameDB *n = [MCNickNameDB new];
? ? ? ? ? ? ? ? n.conversationId = ext[EASE_GroupID__Key];
? ? ? ? ? ? ? ? n.niname = ext[EASE_Nicname_Group_Key];
? ? ? ? ? ? ? ? n.headimg = ext[EASE_Avatar_Group_Key];
? ? ? ? ? ? ? ? BOOL nick = [nickNameDB.niname isEqualToString:n.niname];
? ? ? ? ? ? ? ? BOOL img = [nickNameDB.headimg isEqualToString:n.headimg];
? ? ? ? ? ? ? ? if (!nick || !img) {
? ? ? ? ? ? ? ? ? ? [MCNickNameDB deleteObjectsByCriteria:[NSString stringWithFormat:@" WHERE conversationId = %@ ",n.conversationId]];
? ? ? ? ? ? ? ? ? ? [n save];
? ? ? ? ? ? ? ? ? ? MCNickNameDB *nickNameDB2 = [MCNickNameDB findFirstByCriteria:[NSString stringWithFormat:@" WHERE conversationId = %@ ",n.conversationId]];
? ? ? ? ? ? ? ? ? ? DLog(@"%@",nickNameDB2);
? ? ? ? ? ? ? ? }
?? ? ? ? ? ? ? ?
? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? MCNickNameDB *n = [MCNickNameDB new];
? ? ? ? ? ? ? ? n.conversationId = ext[EASE_GroupID__Key];
? ? ? ? ? ? ? ? n.niname = ext[EASE_Nicname_Group_Key];;
? ? ? ? ? ? ? ? n.headimg = ext[EASE_Avatar_Group_Key];
? ? ? ? ? ? ? ? [n save];
? ? ? ? ? ? }
?
?? ? ? ? ? ?
? ? ? ? }
? ? ? ? BOOL needShowNotification = (message.chatType != EMChatTypeChat) ? [self _needShowNotification:message.conversationId] : YES;
?? ? ? ?
#ifdef REDPACKET_AVALABLE
? ? ? ? /**
?? ? ? ? *? 屏蔽紅包被搶消息的提示
?? ? ? ? */
? ? ? ? NSDictionary *dict = message.ext;
? ? ? ? needShowNotification = (dict && [dict valueForKey:RedpacketKeyRedpacketTakenMessageSign]) ? NO : needShowNotification;
#endif
?? ? ? ?
? ? ? ? UIApplicationState state = [[UIApplication sharedApplication] applicationState];
? ? ? ? if (needShowNotification) {
#if !TARGET_IPHONE_SIMULATOR
? ? ? ? ? ? switch (state) {
? ? ? ? ? ? ? ? case UIApplicationStateActive:
? ? ? ? ? ? ? ? ? ? [self.mainVC playSoundAndVibration];
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case UIApplicationStateInactive:
? ? ? ? ? ? ? ? ? ? [self.mainVC playSoundAndVibration];
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case UIApplicationStateBackground:
? ? ? ? ? ? ? ? ? ? [self.mainVC showNotificationWithMessage:message];
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? default:
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? }
#endif
? ? ? ? }
?? ? ? ?
? ? ? ? if (_chatVC == nil) {
? ? ? ? ? ? _chatVC = [self _getCurrentChatView];
? ? ? ? }
? ? ? ? BOOL isChatting = NO;
? ? ? ? if (_chatVC) {
? ? ? ? ? ? isChatting = [message.conversationId isEqualToString:_chatVC.conversation.conversationId];
? ? ? ? }
? ? ? ? if (_chatVC == nil || !isChatting || state == UIApplicationStateBackground) {
? ? ? ? ? ? [self _handleReceivedAtMessage:message];
?? ? ? ? ? ?
? ? ? ? ? ? if (self.conversationListVC) {
? ? ? ? ? ? ? ? [_conversationListVC refresh];
? ? ? ? ? ? }
?? ? ? ? ? ?
? ? ? ? ? ? if (self.mainVC) {
? ? ? ? ? ? ? ? [_mainVC setupUnreadMessageCount];
? ? ? ? ? ? }
? ? ? ? ? ? return;
? ? ? ? }
?? ? ? ?
? ? ? ? if (isChatting) {
? ? ? ? ? ? isRefreshCons = NO;
? ? ? ? }
? ? }
?? ?
? ? if (isRefreshCons) {
? ? ? ? if (self.conversationListVC) {
? ? ? ? ? ? [_conversationListVC refresh];
? ? ? ? }
?? ? ? ?
? ? ? ? if (self.mainVC) {
? ? ? ? ? ? [_mainVC setupUnreadMessageCount];
? ? ? ? }
? ? }
}
?
以上,,單聊的基本完成。。。。如果有遺漏,請留言,,
下面是群聊
其實群聊跟單聊是一樣,,不過,就是給ext擴展再添加一個群的名稱,一個群的頭像。
然后在拿屬性的時候,劃分一下是群聊還是單聊。。。
這里就不一一到來,上面有標注群聊的大家可以看一下~~~
?
轉載于:https://www.cnblogs.com/LusYoHo/p/6371249.html
總結
- 上一篇: mysql DbProviderFac
- 下一篇: 移动端H5页面注意事项