XMPPFramework - How can I update my own avatar image?

女生的网名这么多〃 提交于 2019-11-29 02:37:41
Ronak Arora
- (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];
    });
}

#import "XMPPvCardTemp.h"

   - (void)updateAvatar:(UIImage *)avatar{  
  NSData *imageData1 = UIImageJPEGRepresentation(avatar,0.5);
        NSXMLElement *vCardXML = [NSXMLElement elementWithName:@"vCard" xmlns:@"vcard-temp"];
        NSXMLElement *photoXML = [NSXMLElement elementWithName:@"PHOTO"];
        NSXMLElement *typeXML = [NSXMLElement elementWithName:@"TYPE"stringValue:@"image/jpeg"];
        NSXMLElement *binvalXML = [NSXMLElement elementWithName:@"BINVAL" stringValue:[imageData1 base64Encoding]];

        [photoXML addChild:typeXML];
        [photoXML addChild:binvalXML];
        [vCardXML addChild:photoXML];
        XMPPvCardTemp *myvCardTemp = [[[self appDelegate] xmppvCardTempModule]myvCardTemp];
        if (myvCardTemp) {
            [myvCardTemp setPhoto:imageData1];
            [[[self appDelegate] xmppvCardTempModule] updateMyvCardTemp
             :myvCardTemp];

        }
        else{

            XMPPvCardTemp *newvCardTemp = [XMPPvCardTemp vCardTempFromElement:vCardXML];
            [[[self appDelegate] xmppvCardTempModule] updateMyvCardTemp:newvCardTemp];
        }
     }

From the XMPP Core RFC, <error type='wait'> means:

retry after waiting (the error is temporary)

so your code should wait a while and re-send the request.

(This is assuming that you are actually sending a base64-encoded JPEG image as the BINVAL of your vCard. The reply from the server doesn't correspond to the request you say you sent, so I'm assuming you've edited both. It would be better to include the exact request and reply in your question, but truncate the base64-encoded image to a few characters for concision.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!