Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
468 views
in Technique[技术] by (71.8m points)

ios - XMPPFramework - How can I update my own avatar image?

I am developing an application in that I want to update my avatar image. I am following XEP-0153 guidelines to update my avatar image and I constructed an NSXMLElement correspond to the following code in XEP-0153 and sent that element through XMPPStream.

<iq from='juliet@capulet.com' 
    type='set'
    id='vc1'>
  <vCard xmlns='vcard-temp'>
    <PHOTO>
      <TYPE>image/jpeg</TYPE>
      <BINVAL>
        Base64-encoded-avatar-file-here!
      </BINVAL>
    </PHOTO>
  </vCard>
</iq>

The server responses the following error:

<iq xmlns="jabber:client" type="error" id="vc1" to="vvreddy50@gmail.com/83557F96">
<vCard xmlns="vcard-temp">
      <photo>
        <type>image/jpeg</type>
        <binval>Base64-encoded-avatar-file-here</binval>
      </photo>
</vCard>
<error code="500" type="wait">
      <internal-server-error xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">
      </internal-server-error>
</error>
</iq>

Instead of <iq to='juliet@capulet.com' type='result' id='vc1'/>

Please can anyone post the code or the link related to update avatar image? Thanks in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
- (void)updateAvatar:(UIImage *)avatar 
{
    NSData *imageData = UIImagePNGRepresentation(avatar);
    dispatch_queue_t queue = dispatch_queue_create("queue", DISPATCH_QUEUE_PRIORITY_DEFAULT);
    dispatch_async(queue, ^{
        XMPPvCardTempModule *vCardTempModule = [[XMPPHandler sharedInstance] xmppvCardTempModule];
        XMPPvCardTemp *myVcardTemp = [vCardTempModule myvCardTemp];
        [myVcardTemp setName:[NSString stringWithFormat:@"%@",name.text]];
        [myVcardTemp setPhoto:imageData];
        [vCardTempModule updateMyvCardTemp:myVcardTemp];
    });
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...