Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XMPPFramework - Nickname not updated if vCard is not already created

Problem comes when a new user registers with XMPP. I am unable to set nickname on vCard, however if vCard of a user already exists then same piece of code works fine.

dispatch_queue_t queue = dispatch_queue_create("queue", DISPATCH_QUEUE_PRIORITY_DEFAULT);
dispatch_async(queue, ^{

    XMPPvCardCoreDataStorage *xmppvCardStorage = [XMPPvCardCoreDataStorage sharedInstance];
    XMPPvCardTempModule *xmppvCardTempModule = [[XMPPvCardTempModule alloc] initWithvCardStorage:xmppvCardStorage];
    [xmppvCardTempModule  activate:[self xmppStream]];

    XMPPvCardTemp *myVcardTemp = [xmppvCardTempModule myvCardTemp];

    if (myVcardTemp == nil) {
       // I am stuck here, unable to create empty VCard for new User
    }
    else {
        [myVcardTemp setNickname:@"iphone"];
        [xmppvCardTempModule updateMyvCardTemp:myVcardTemp];
    }

});

Any clue for creating vcard for first time in xmpp?

like image 839
Haris Avatar asked Sep 19 '13 10:09

Haris


1 Answers

XMPPvCardTemp *myvCardTemp = [xmppvCardTempModule myvCardTemp];
if (!myvCardTemp) 
{
    NSXMLElement *vCardXML = [NSXMLElement elementWithName:@"vCard" xmlns:@"vcard-temp"];
    XMPPvCardTemp *newvCardTemp = [XMPPvCardTemp vCardTempFromElement:vCardXML];
    [newvCardTemp setNickname:@"nick"];
    [xmppvCardTempModule updateMyvCardTemp:newvCardTemp];
}
else
{
    //Set Values as normal
}
like image 118
Haris Avatar answered Nov 06 '22 05:11

Haris