1.首先环信聊天是不支持头像跟昵称管理的,所以要想办法把昵称跟头像放在自己的服务器上来管理
- (void)_sendMessage:(EMMessage *)message
{
NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:message.ext];
NSDictionary *userData = [XQUserData getUserData];
[dict setValue:userData[@"nickName"] forKey:@"userName"];
[dict setValue:userData[@"headImg"] forKey:@"userPic”];
}
在下面这个方法中获取解析头像
- (id<IMessageModel>)messageViewController:(EaseMessageViewController *)viewController
modelForMessage:(EMMessage *)message
{
id<IMessageModel> model = nil;
model = [[EaseMessageModel alloc] initWithMessage:message];
if (model.message.ext) {
model.avatarURLPath = model.message.ext[@"userPic"];
//昵称
model.nickname = model.message.ext[@"userName"];
//头像占位图
model.failImageName = @"imageDownloadFail";
}else{
model.avatarImage = [UIImage imageNamed:@"EaseUIResource.bundle/user"];
//头像占位图
model.failImageName = @"imageDownloadFail";
}
return model;
}
只需要更改两处就可以解决了,只需要跟搞安卓协商好这两个Key就可以很好的完成安卓跟iOS互相聊天是显示昵称跟头像了.
网友评论