Registration is simple:
Define a method in appdelegate as follows:
-(Bool) registeritalk :( nsstring *) un pwd :( nsstring *) pwd
{
Isloginoperation = no;
Self. Username = UN;
Self. Password = PWD;
Return [self connect];
}
Isloginoperation determines whether to log on or register. Before registering, you must call [self connect];
Call the registration method provided by XMPP in this proxy method
-(Void) xmppstreamdidconnect :( xmppstream *) sender
{
Ddlogverbose (@ "% @: % @", this_file, this_method );
Isxmppconnected = yes;
Nserror * error = nil;
If (isloginoperation ){
[[Self xmppstream] authenticatewithpassword: Password error: & error];
} Else
{
If (! [[Self xmppstream] registerwithpassword: Password error: & error]) {
Ddlogerror (@ "error register", error );
}
}
}
You can achieve registration.
It's easy to add friends. XMPP provides methods.
/**
* Adds the given user to the roster and requests permission to receive presence information from them.
**/
-(Void) adduser :( xmppjid *) jid withnickname :( nsstring *) optionalname;