以前的項目由於用戶信息以及好友關係是由服務器管理的,因此在開發的時候用戶的頭像以及用戶的暱稱是放在服務器中管理的。web
個人環信版本是最新的V3.2版本,其餘的版本暫且未知,不過我想模式應該八九不離十.
/// 彈出單聊界面窗口 EaseMessageViewController *chatController = [[EaseMessageViewController alloc] initWithConversationChatter:@"8001" conversationType:EMConversationTypeChat];
/// 重寫EaseMessageViewController.h中的方法. - (id<IMessageModel>)messageViewController:(EaseMessageViewController *)viewController modelForMessage:(EMMessage *)message { if (message.direction == EMMessageDirectionSend){ /// 用戶發送 //用戶能夠根據本身的用戶體系,根據message設置用戶暱稱和頭像 id<IMessageModel> model = nil; model = [[EaseMessageModel alloc] initWithMessage:message]; model.avatarImage = [UIImage imageNamed:@"EaseUIResource.bundle/user"];//默認頭像 NSString *url = [NSString ddl_webImageRequestWithUrl:self.userInformation.url]; model.avatarURLPath = url;//頭像網絡地址 model.nickname = self.userInformation.username;//用戶暱稱 return model; } else { //用戶能夠根據本身的用戶體系,根據message設置用戶暱稱和頭像 id<IMessageModel> model = nil; model = [[EaseMessageModel alloc] initWithMessage:message]; model.avatarImage = [UIImage imageNamed:@"EaseUIResource.bundle/user"];//默認頭像 NSString *url = [NSString ddl_webImageRequestWithUrl:self.friend_url]; model.avatarURLPath = url;//頭像網絡地址 model.nickname = self.friend_username;//用戶暱稱 return model; } }