Xmppframework iOS development (5) Getting friend information and adding and deleting friends

Source: Internet
Author: User
Tags call back

Original address: xmppframework iOS development (5) Getting friend information and adding and deleting friends

Friend list and friend business card

[_ Xmpproster fetchroster]; // obtain a friend list // obtain a friend node-(void) xmpproster :( xmpproster *) sender didrecieverosteritem :( nsxmlelement *) item // obtain the friends list-(void) xmpprosterdidendpopulating :( xmpproster *) sender // request the contact name card information on the server-(void) fetchvcardtempforjid :( xmppjid *) jid; // request the contact's business card. If the database does not, send the business card Request-(void) fetchvcardtempforjid :( xmppjid *) jid ignorestorage :( bool) ignorestorage; // obtain the contact's business card. If the database has one, no blank is returned, and the system crawls-(xmppvcardtemp *) vcardtempforjid :( xmppjid *) jid shouldfetch :( bool) shouldfetch; // update your business card information-(void) updatemyvcardtemp :( xmppvcardtemp *) vcardtemp; // call back (void) xmppvcardtempmodule (xmppvcardtempmodule *) vcardtempmodule didreceivevcardtemp :( xmppvcardtemp *) vcardtemp forjid :( xmppjid *) jid

Add friends

// Name is the user account-(void) xmppaddfriendsubscribe :( nsstring *) name {// xmpphost is the server name, host name xmppjid * jid = [xmppjid jidwithstring: [nsstring stringwithformat: @ "% @", name, xmpphost]; // [presence addattributewithname: @ "subscribe" stringvalue: @ "friend"]; [xmpproster subscribepresencetouser: jid];}

// Receive a friend adding request-(void) xmpproster :( xmpproster *) sender didreceivepresencesubscriptionrequest :( xmpppresence *) Presence {// obtain the friend status nsstring * presencetype = [nsstring stringwithformat: @ "% @", [presence type]; // online/offline // The requested user nsstring * presencefromuser = [nsstring stringwithformat: @ "% @", [[presence from] user]; nslog (@ "presencetype: % @", presencetype); nslog (@ "presence2: % @ sender2: % @", presence, sender); xmppjid * jid = [xmppjid jidwithstring: presencefromuser]; // receives a friend adding request [xmpproster acceptpresencesubscriptionrequestfrom: jid andaddtoroster: Yes];}

Delete friends

// Delete a friend. The name is a friend account-(void) removebuddy :( nsstring *) name {xmppjid * jid = [xmppjid jidwithstring: [nsstring stringwithformat: @ "% @", name, xmpphost]; [self xmpproster] removeuser: jid];}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.