XMPP協(xié)議 -- XMPPvCard

激活模塊:

_vCardStorage = [XMPPvCardCoreDataStorage sharedInstance];
_vCardTempModule = [[XMPPvCardTempModule alloc] initWithvCardStorage:_vCardStorage];
_vCardAvatarModule = [[XMPPvCardAvatarModule alloc] initWithvCardTempModule:_vCardTempModule];
[_vCardTempModule addDelegate:self delegateQueue:dispatch_get_main_queue()];
[_vCardAvatarModule addDelegate:self delegateQueue:dispatch_get_main_queue()];
[_vCardTempModule activate:_xmppStream];
[_vCardAvatarModule activate:_xmppStream];

更新名片信息:

/// 更新名片信息
- (void)updateVCardMsg
{
    XMPPvCardTemp *vcard = self.vCardTempModule.myvCardTemp;
    /// 自定義xml擴展名片內(nèi)容
    DDXMLNode *node1 = [DDXMLNode elementWithName:@"key" stringValue:@"13877977999"];
    DDXMLNode *node2 = [DDXMLNode elementWithName:@"key" stringValue:@"http://imgtu.4934501486627131.jpg"];
    DDXMLNode *node3 = [DDXMLNode elementWithName:@"key" stringValue:@"美國"];
    DDXMLNode *node4 = [DDXMLNode elementWithName:@"key" stringValue:@"廣東"];
    DDXMLNode *node5 = [DDXMLNode elementWithName:@"key" stringValue:@"廣州"];
    DDXMLNode *node6 = [DDXMLNode elementWithName:@"key" stringValue:@"男"];
    DDXMLNode *node7 = [DDXMLNode elementWithName:@"key" stringValue:@"aaaa"];
    vcard.nickname = @"nickname";
    [vcard addChild:node1];
    [vcard addChild:node2];
    [vcard addChild:node3];
    [vcard addChild:node4];
    [vcard addChild:node5];
    [vcard addChild:node6];
    [vcard addChild:node7];
    /// 向服務(wù)器更新名片
    [_vCardTempModule updateMyvCardTemp:vcard];
}

vCard代理:XMPPvCardTempModuleDelegate

代理在登錄成功后 和 調(diào)用 [_vCardTempModule updateMyvCardTemp:vcard]; 方法后都會有一次回調(diào)。

/// 獲取到個人信息
- (void)xmppvCardTempModule:(XMPPvCardTempModule *)vCardTempModule 
didReceivevCardTemp:(XMPPvCardTemp *)vCardTemp forJID:(XMPPJID *)jid {}

發(fā)送IQ消息, 獲取名片內(nèi)容:

/// 發(fā)送IQ消息, 獲取名片內(nèi)容
- (void)getVCardMsgWithUserID:(NSString *)userID
{
    XMPPIQ *iq = [XMPPIQ iqWithType:@"get"];
    XMPPJID *JID = [XMPPJID jidWithUser:userID domain:@"domain" resource:@"resource"];
    [iq addAttributeWithName:@"to" stringValue:JID.bare];
    NSXMLElement *element = [NSXMLElement elementWithName:@"vCard" xmlns:@"vcard-temp"];
    [iq addChild:element];
    [_xmppStream sendElement:iq];
}

發(fā)送IQ消息后都會在 代理方法有回調(diào)

- (BOOL)xmppStream:(XMPPStream *)sender didReceiveIQ:(XMPPIQ *)iq
{

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容