There are two ways to do that.
- Having database of users on server where you can fetch all users on server.
- Using Search api of openfire. If you are not using any webservice, you can implement xep-0055
As a response of search you can get a list of jids, from where you have to select one. Now again there are two options to add that jid in your roster list
Install User service plugin and use add roster api provided by openfire.
From app as below
XMPPJID *newBuddy = [XMPPJID jidWithString:@"jid"]; [xmppRoster addUser:newBuddy withNickname:nil];
Other user will get it via presence
if([presenceType isEqualToString:@"subscribe"])
{
NSXMLElement *presenceToRequest = [NSXMLElement elementWithName:@"presence"];
[presenceToRequest addAttributeWithName:@"type" stringValue:@"subscribed"];
[presenceToRequest addAttributeWithName:@"to" stringValue:[NSString stringWithFormat:@"%@", [presence fromStr]]];
[presenceToRequest addAttributeWithName:@"from" stringValue:[NSString stringWithFormat:@"%@", [presence toStr]]];
[[self xmppStream] sendElement:presenceToRequest];
}
This list out iq used for various purpose.
PS: Links with openfire will work after modifying openfire ip and port