XMPPFrameWork IOS 開發(五)擷取好友資訊和添加移除朋友

來源:互聯網
上載者:User

原始地址: XMPPFrameWork IOS 開發(五)擷取好友資訊和添加移除朋友

好友名單和好友名片

[_xmppRoster fetchRoster];//擷取好友名單//擷取到一個好友節點- (void)xmppRoster:(XMPPRoster *)sender didRecieveRosterItem:(NSXMLElement *)item//擷取完好友名單- (void)xmppRosterDidEndPopulating:(XMPPRoster *)sender//到伺服器上請求連絡人名片資訊- (void)fetchvCardTempForJID:(XMPPJID *)jid;//請求連絡人的名片,如果資料庫有就不請求,沒有就發送名片請求- (void)fetchvCardTempForJID:(XMPPJID *)jid ignoreStorage:(BOOL)ignoreStorage;//擷取連絡人的名片,如果資料庫有就返回,沒有返回空,併到伺服器上抓取- (XMPPvCardTemp *)vCardTempForJID:(XMPPJID *)jid shouldFetch:(BOOL)shouldFetch;//更新自己的名片資訊- (void)updateMyvCardTemp:(XMPPvCardTemp *)vCardTemp;//擷取到一盒連絡人的名片資訊的回調- (void)xmppvCardTempModule:(XMPPvCardTempModule *)vCardTempModule         didReceivevCardTemp:(XMPPvCardTemp *)vCardTemp                      forJID:(XMPPJID *)jid

添加好友

//name為使用者帳號- (void)XMPPAddFriendSubscribe:(NSString *)name  {    //XMPPHOST 就是伺服器名,  主機名稱        XMPPJID *jid = [XMPPJID jidWithString:[NSString stringWithFormat:@"%@@%@",name,XMPPHOST]];      //[presence addAttributeWithName:@"subscription" stringValue:@"好友"];      [xmppRoster subscribePresenceToUser:jid];        }

//收到添加好友的請求- (void)xmppRoster:(XMPPRoster *)sender didReceivePresenceSubscriptionRequest:(XMPPPresence *)presence  {      //取得好友狀態      NSString *presenceType = [NSString stringWithFormat:@"%@", [presence type]]; //online/offline      //請求的使用者      NSString *presenceFromUser =[NSString stringWithFormat:@"%@", [[presence from] user]];      NSLog(@"presenceType:%@",presenceType);            NSLog(@"presence2:%@  sender2:%@",presence,sender);            XMPPJID *jid = [XMPPJID jidWithString:presenceFromUser];      //接收添加好友請求    [xmppRoster acceptPresenceSubscriptionRequestFrom:jid andAddToRoster:YES];    }  

移除朋友

//移除朋友,name為好友帳號- (void)removeBuddy:(NSString *)name  {      XMPPJID *jid = [XMPPJID jidWithString:[NSString stringWithFormat:@"%@@%@",name,XMPPHOST]];            [self xmppRoster] removeUser:jid];  }
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.