How can i get presence of any specific user with user id.
I mean to say without add that user in roster list.
Please help me regarding this.
Thanks in advance.
How can i get presence of any specific user with user id.
I mean to say without add that user in roster list.
Please help me regarding this.
Thanks in advance.
I assume you're talking about the iOS XMPPFramework. If not, please ignore this answer. You can send a directed presence to another user like this:
XMPPPresence *presence = [[XMPPPresence alloc] initWithType:@"probe" to:someJid];
[_xmppStream sendElement:presence];
Where _xmppStream is a open and connected XMPPStream.
Notice however, that most XMPP Servers will not allow reply to this kind of directed presences if the other user is not in your roster. If you're managing your own XMPP server, you can modify it to allow this kind of operations.
You can ask for any users presence by making call of following plugin url
http://{SERVER_NAME}:9090/plugins/presence/status?jid=USERID@SERVER_NAME&type=text
EX:
[NSURLConnection sendAsynchronousRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://SERVER_NAME:9090/plugins/presence/status?jid=ANYUSER@SERVER_NAME&type=text"]] queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
if(connectionError==nil)
NSLog(@"plugins response ===%@",[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
}];
It will return "online" foractive users and "unavailble" for offline users.Please take care about the server setting on openfire server shown in image.