美文网首页
解决环信聊天头像跟昵称的问题

解决环信聊天头像跟昵称的问题

作者: 乐毅ya | 来源:发表于2018-02-26 11:46 被阅读0次

    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互相聊天是显示昵称跟头像了.

    相关文章

      网友评论

          本文标题:解决环信聊天头像跟昵称的问题

          本文链接:https://www.haomeiwen.com/subject/oegexftx.html