【问题标题】:Unable to get VCard using XMPPFramework无法使用 XMPPFramework 获取 VCard
【发布时间】:2016-01-06 11:13:01
【问题描述】:

我无法使用此代码通过 XMPPFramework 获取 VCard 信息

XMPPJID *jid = [XMPPJID jidWithString:[NSString stringWithFormat:@"%@@myserver", myId]];
XMPPvCardTemp *vcard = [[DBChatManager shareInstance].xmppvCardTempModule vCardTempForJID:jid shouldFetch:YES];

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

【问题讨论】:

    标签: ios xmppframework


    【解决方案1】:

    经过大量搜索,我发现在 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
    

    根据我的情况使用。

    【讨论】:

      【解决方案2】:

      验证后使用 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);
          }
      

      【讨论】:

        猜你喜欢
        • 2014-02-19
        • 1970-01-01
        • 1970-01-01
        • 2017-10-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-07-15
        • 2017-03-25
        相关资源
        最近更新 更多