1

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.

Amit Bhavsar
  • 1,273
  • 12
  • 23

2 Answers2

2

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.

Matías R
  • 2,195
  • 1
  • 14
  • 12
0

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.enter image description here

cjd
  • 549
  • 3
  • 11
  • I got "Unavailable" for the user when he/she is offline, But got "null" when that perticular user become online. – Amit Bhavsar Dec 20 '14 at 13:46
  • It should not be the case..Let me check once again in my code. – cjd Dec 22 '14 at 07:14
  • I tested with my code,seems to be working. Please check the servername and run http://{SERVER_NAME}:9090/plugins/presence/status?jid=USERID@SERVER_NAME&type=text on browser first to check – cjd Dec 22 '14 at 07:21