Set the chat/Avatar in QuickBlox QBUUser in iOS Ch

2019-06-24 05:06发布

问题:

Here in QuickBlox we get the QBUUser instance of each user registered with the QuickBlox . 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 . Is this right way to set avatar Url or if any other way exist let me know. Thanks in Advance.

回答1:

Finally i satisfied with customData property in QBUUser.

I just created a dictionary and set url in that dictionary within some Key.

Than created its JSON string and set it in the QBUUser property customData and updated it and it worked. 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
created at:2014-12-26 13:04:56 +0000 updated at:2014-12-26 13:05:02 +0000
externalUserID:45454 blobID:0 facebookID:(null) twitterID:(null)
full name:blabla
email:blabla@gmail.com
login:blabla@gmail.com
phone:9999999999
tags:(null)
lastRequestAt:2014-12-26 13:39:24 +0000
customData:{"user_picture":"myprofileurl.png"} website:(null)



回答2:

This is the right way

Also there is a blobId field to set the id of file from Content module

Here is an example how to do it http://quickblox.com/developers/SimpleSample-users-ios#Updating_a_profile_picture_.28avatar.29