如何从XMPP/OpenFire检索iOS中的vCard [英] How to retrieve vCard in iOS from XMPP/OpenFire
本文介绍了如何从XMPP/OpenFire检索iOS中的vCard的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
顾名思义,我正在尝试使用以下XMPPFrameworks方法之一为用户检索电子名片:
As the name suggests I am trying to retrieve a vCard for a user using one of the next XMPPFrameworks methods:
- (XMPPvCardTemp *)fetchvCardTempForJID:(XMPPJID *)jid;
- (XMPPvCardTemp *)fetchvCardTempForJID:(XMPPJID *)jid useCache:(BOOL)useCache;
我当前的实现是:
dispatch_queue_t queue = dispatch_queue_create("queue", DISPATCH_QUEUE_PRIORITY_DEFAULT);
dispatch_async(queue, ^{
XMPPvCardCoreDataStorage* xmppvCardStorage = [XMPPvCardCoreDataStorage sharedInstance];
XMPPvCardTempModule* m = [[XMPPvCardTempModule alloc] initWithvCardStorage:xmppvCardStorage];
[m fetchvCardTempForJID:[sender myJID] ignoreStorage:YES];
NSLog(@"%@",xmppvCardStorage.description);
});
上面的代码不起作用,如果当前的方法正确,我也想知道如何记录数据.
The code above is not working and also I wanted to know how can I log the data, if the current approach is the right one.
推荐答案
首先创建appdelegate的实例:
First create a instance of the appdelegate:
-(AppDelegate *) appDelegate{
return (AppDelegate *)[UIApplication sharedApplication].delegate;}
然后使用以下代码检索电子名片:
Then use below code to retrieve the vCard:
XMPPvCardTemp *vCard =[[self appDelegate].xmppvCardTempModule vCardTempForJID:[self appDelegate].xmppStream.myJID.bareJID shouldFetch:YES];
这里我使用了当前用户的JID.您可以使用其他用户的JID,但请确保它应该是XMPPJID对象.
Here I have used the current user JID. You can used other users JID, but make sure that it should be a XMPPJID object.
使用XMPPvCardTemp对象记录它
Log it using the object of the XMPPvCardTemp
NSLog(@"%@", vCard.nickname);
NSLog(@"%@", vCard.name);
NSLog(@"%@", vCard.emailAddresses);
NSLog(@"%@", vCard.formattedName);
NSLog(@"%@", vCard.givenName);
NSLog(@"%@", vCard.middleName);
这篇关于如何从XMPP/OpenFire检索iOS中的vCard的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文