XMPPFramework - 如何更新自己的头像图像? [英] XMPPFramework - How can I update my own avatar image?
本文介绍了XMPPFramework - 如何更新自己的头像图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个应用程序,因为我想更新我的头像图像。我按照 XEP-0153
指南来更新我的头像图像,我构建了一个 NSXMLElement
对应于以下代码 XEP-0153
并通过 XMPPStream
发送该元素。
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>
服务器响应以下错误:
<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>
而不是< iq to='juliet@capulet.com'类型='结果'id ='vc1'/>
请问任何人都可以发布与更新头像图片相关的代码或链接吗?在此先感谢。
Please can anyone post the code or the link related to update avatar image? Thanks in advance.
推荐答案
- (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];
});
}
这篇关于XMPPFramework - 如何更新自己的头像图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文