简体   繁体   English

在iOS Chat中设置QuickBlox QBUUser中的聊天/头像

[英]Set the chat/Avatar in QuickBlox QBUUser in iOS Chat

Here in QuickBlox we get the QBUUser instance of each user registered with the QuickBlox . 在QuickBlox中,我们获得了使用QuickBlox注册的每个用户的QBUUser实例。 But i did not found any property to set the avatar url for profile photo and update it. 但我没有找到任何属性来设置个人资料照片的头像网址并更新它。 I was thinking to set url in property customData . 我想在属性customData中设置url。 Is this right way to set avatar Url or if any other way exist let me know. 这是设置头像Url的正确方法,或者是否存在任何其他方式让我知道。 Thanks in Advance. 提前致谢。

Finally i satisfied with customData property in QBUUser. 最后我对QBUUser中的customData属性感到满意。

I just created a dictionary and set url in that dictionary within some Key. 我刚刚在一些Key中创建了一个字典并在该字典中设置了url。

Than created its JSON string and set it in the QBUUser property customData and updated it and it worked. 然后创建它的JSON字符串并将其设置在QBUUser属性customData中并更新它并且它工作。 Here is its small code snippet. 这是它的小代码片段。

        QBUUser *user = [QBUUser user];
        user.ID = qbUserID; // Set User id so it updates that user
       NSDictionary *dict = @{kUserPicture:@"myprofileurl.png"}; // Created dictionary to store Avatar URl
       user.customData=[dict JSONRepresentation]; // Created its Json String

      [QBRequest updateUser:user successBlock:^(QBResponse *response, QBUUser *user) {
            NSLog(@"customData %@",user.customData);
        } errorBlock:^(QBResponse *response) {

    }];

And in success block i got this response 在成功阻止我得到了这个回应

ID:qbID ID:qbID
created at:2014-12-26 13:04:56 +0000 updated at:2014-12-26 13:05:02 +0000 创建时间:2014-12-26 13:04:56 +0000更新时间:2014-12-26 13:05:02 +0000
externalUserID:45454 blobID:0 facebookID:(null) twitterID:(null) externalUserID:45454 blobID:0 facebookID:(null)twitterID:(null)
full name:blabla 全名:blabla
email:blabla@gmail.com 电子邮件:blabla@gmail.com
login:blabla@gmail.com 登录:blabla@gmail.com
phone:9999999999 电话:9999999999
tags:(null) 标签:(空)
lastRequestAt:2014-12-26 13:39:24 +0000 lastRequestAt:2014-12-26 13:39:24 +0000
customData:{"user_picture":"myprofileurl.png"} website:(null) customData:{“user_picture”:“myprofileurl.png”}网站:(null)

This is the right way 这是正确的方法

Also there is a blobId field to set the id of file from Content module 还有一个blobId字段用于设置Content模块中的文件ID

Here is an example how to do it http://quickblox.com/developers/SimpleSample-users-ios#Updating_a_profile_picture_.28avatar.29 以下是如何操作的示例http://quickblox.com/developers/SimpleSample-users-ios#Updating_a_profile_picture_.28avatar.29

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM