无法使用XMPPFramework获得VCard

时间:2016-01-06 11:13:02

标签: ios xmppframework

我无法使用此代码

使用XMPPFramework获取VCard信息
XMPPJID *jid = [XMPPJID jidWithString:[NSString stringWithFormat:@"%@@myserver", myId]];
XMPPvCardTemp *vcard = [[DBChatManager shareInstance].xmppvCardTempModule vCardTempForJID:jid shouldFetch:YES];

它返回nil作为响应,但在日志中我看到它获取VCard。虽然我可以成功更新和创建VCard。

2 个答案:

答案 0 :(得分:0)

经过大量搜索,我发现在课堂上XMPPvCardTempModule.m后面的行被我的团队成员评论

XMPPvCardTemp *vCardTemp = [XMPPvCardTemp vCardTempCopyFromIQ:iq];
if (vCardTemp != nil)
{
    [self _updatevCardTemp:vCardTemp forJID:[iq from]];

    return YES;
}

取消注释上面的行后,我可以在

中获取针对JID的VCard详细信息
- (void)xmppvCardTempModule:(XMPPvCardTempModule *)vCardTempModule
    didReceivevCardTemp:(XMPPvCardTemp *)vCardTemp
                 forJID:(XMPPJID *)jid

并根据我的情况使用它。

答案 1 :(得分:0)

认证后使用XMPPvCardCoreDataStorage和XMPPvCardTempModule

- (void)xmppStreamDidAuthenticate:(XMPPStream *)sender {

    [self goOnline];
    if ([xmppStream isAuthenticated]) {
        NSLog(@"authenticated");
        xmppvCardStorage = [[XMPPvCardCoreDataStorage alloc] initWithInMemoryStore];
        xmppvCardTempModule = [[XMPPvCardTempModule alloc] initWithvCardStorage:xmppvCardStorage];
        [xmppvCardTempModule activate:[self xmppStream]];
        [xmppvCardTempModule addDelegate:self delegateQueue:dispatch_get_main_queue()];
        [xmppvCardTempModule fetchvCardTempForJID:[sender myJID] ignoreStorage:YES];
    }

}

- (void)xmppvCardTempModule:(XMPPvCardTempModule *)vCardTempModule didReceivevCardTemp:(XMPPvCardTemp *)vCardTemp forJID:(XMPPJID *)jid{

        XMPPvCardTemp *vCard = [xmppvCardStorage vCardTempForJID:jid xmppStream:xmppStream];
        NSLog(@"%@", vCard.description);
    }