How to be sure that my XMPP user does not have vCard using XMPPFramework?

I am developing an XMPP iOS-based XMPPFramework application and ejabberd Community Edition server , and I am playing with vCard management.

During my experiments, I found out that when requesting vCard for a user through something like:

[vCardTempModule fetchvCardTempForJID:myJID];

Then the delegate method will not be called if the user does not have vCard on the server.

Is there a way to be 100% sure that the user does not have vCard through an explicit response from the server?

Or should I just think that the user does not have a vCard after a delay of n seconds without any feedback from the delegate? (which would be ambiguous with a network latency situation, which can be very common in a mobile environment)

+4
source share
1 answer

In XEP-0054 XMPPvCardTempModule.m

You need to do it

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


    XMPPvCardTemp *myvCardTemp = [self myvCardTemp];//check if exist or not

    if (!myvCardTemp)//if not then create a new vcard
    {
        NSXMLElement *vCardXML = [NSXMLElement elementWithName:@"vCard" xmlns:@"vcard-temp"];
        XMPPvCardTemp *newvCardTemp = [XMPPvCardTemp vCardTempFromElement:vCardXML];
        [newvCardTemp setNickname:userName];
        [self updateMyvCardTemp:newvCardTemp];
    }

}

Hope this works for you :)

+2
source

Source: https://habr.com/ru/post/1542064/


All Articles