XMPPFramework: Trying to update nickname on VCard

[亡魂溺海] 提交于 2019-12-12 04:25:23

问题


This question is as simple as its title says: I'm trying to update a user nickname on his VCard but I cannot. I'm using this code:

dispatch_queue_t queue = dispatch_queue_create("queue", DISPATCH_QUEUE_PRIORITY_DEFAULT);
    dispatch_async(queue, ^{
        XMPPvCardTemp *myVcardTemp = [[[self appDelegate] xmppvCardTempModule] myvCardTemp];
        [myVcardTemp setNickname:@"a_nickname"];
        [[[self appDelegate] xmppvCardTempModule] updateMyvCardTemp:myVcardTemp];
    });

I cannot imagine why this piece of code don't want to work while the same piece, but updating photo, is working like a charm:

NSData *imageData = UIImagePNGRepresentation(anImage);
        dispatch_queue_t queue = dispatch_queue_create("queue", DISPATCH_QUEUE_PRIORITY_DEFAULT);
        dispatch_async(queue, ^{
            XMPPvCardTemp *myVcardTemp = [[[self appDelegate] xmppvCardTempModule] myvCardTemp];
            [myVcardTemp setPhoto:imageData];
            [[[self appDelegate] xmppvCardTempModule] updateMyvCardTemp:myVcardTemp];
        });

Any help would be appreciated... this is driving me crazy

NOTES: I'm using OpenFire as XMPP server

And this is the stanza the server returns me when I'm trying to update the nickname

RECV: <iq xmlns="jabber:client" type="result" from="7db55e68-cb18-4826-befd-0eb9269637aa@000.000.000.000" to="7db55e68-cb18-4826-befd-0eb9269637aa@000.000.000.000/2cfc4f88"><chat_jorges xmlns="vcard-temp"><NICKNAME>chat_jorges</NICKNAME></chat_jorges></iq>

(I changed my server's ip for 000.000.000.000)


回答1:


EDIT : I WAS TOTALLY WRONG DON'T READ THIS

Actually when I read the source code of XMPP, I wonder how it could set a value. In XMPPvCardTempBase.h :

#define XMPP_VCARD_SET_STRING_CHILD(Value, Name) NSXMLElement *elem = [self elementForName:(Name)];
//it looks like a get and not a set??

And in XMPPvCardTemp.m :

- (void)setNickname:(NSString *)nick {
    XMPP_VCARD_SET_STRING_CHILD(nick, @"NICKNAME");
}

Maybe there is something as KVC somewhere... Can you try this in the source code:

 - (void)setNickname:(NSString *)nick {
       XMPP_VCARD_SET_STRING_CHILD(nick, @"NICKNAME") = nick ;
   }


来源:https://stackoverflow.com/questions/16525066/xmppframework-trying-to-update-nickname-on-vcard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!