iOS Development--xmppframework--Buddy module (iv)

Source: Internet
Author: User

In the previous few, we discussed the environment configuration, the framework of the import and user login, this one we say friend module.

Before we get to the point, let's start debugging.

First, open the preferences to see if the OpenFire server and MySQL open, remember to open MySQL first, then open OpenFire, then, click Open Admin conconsole,

The following page appears, and it succeeds.

Enter the user name and password, login, this interface appears:

Then, click "Users/Groups" on the navigation bar, the management of users and chat groups appears.

We can see that there are two users, one is the administrator, one is the ordinary user Zhangsan, we click on the left menu, create a new user Wangwu, login password 123456.

On a Mac, there's an app called info, click on it. and select Add account in the menu bar

Select a different "info" account and click Continue.

Click Login, successfully connected, we can go back to the OpenFire console and discover that Zhang San is already logged in.

This is successful, we can use the program and Zhang San Chat.

/////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////

Next is the topic of today, Buddy module.

In the previous method of setting up the module, we added the friend module and activated it.

//Buddy ModuleSelf.xmpproster =[[Xmpproster alloc] initwithrosterstorage:[xmpprostercoredatastorage sharedinstance]]; //do not automatically agree to a friend request[Self.xmpproster Setautoacceptknownpresencesubscriptionrequests:no];    [Self.xmpproster Setautoclearallusersandresources:no]; //do not sync friends list automatically once login is complete[Self.xmpproster Setautofetchroster:no]; //Friends Chat Recording moduleSelf.xmppmessagearchiving =[[Xmppmessagearchiving alloc] Initwithmessagearchivingstorage:[xmppmessagearchivingcoredatastorage        Sharedinstance]]; //Activate[Self.xmpproster Activate:self.xmppStream]; [Self.xmppmessagearchiving Activate:self.xmppStream];

We can use the following proxy method to get a friend's upper and lower line notification:

-(void) Xmppstream: (Xmppstream *) sender Didreceivepresence: (xmpppresence *) Presence {    //  This if set up when stating that the other wants to subscribe you    if ([Presence.type isequaltostring:@ "Subscribe " ]) {        [Self.xmpproster acceptpresencesubscriptionrequestfrom:presence.  from Andaddtoroster:yes];}    }

Received a presence message, of course, we do not have a friend on-line operation, the current code means to receive a friend subscription request, and agree.

-(void) AddUser: (Xmppjid *) Jid withnickname: (NSString *) optionalname;

The function of the above code is to send a request to add a friend. Then, the other party in the above agent received a subscription message, choose to agree or pop-up friend's request.

Next, let's talk about the buddy list module.

iOS Development--xmppframework--Buddy module (iv)

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.