Search code examples
iosxmppxmppframeworkuser-presence

XMPPFramework - Presence not received in iOS


I am trying to send message from simulator to device. On simulator there is one user while on device there is another user. But presence is not being received at any end. I am using XMPPFramework for ios. Here is the code I am using to send presence

NSXMLElement *presence = [NSXMLElement elementWithName:@"presence"];
[presence addAttributeWithName:@"to" stringValue:[NSString stringWithFormat:@"[email protected]"]];
[presence addAttributeWithName:@"type" stringValue:@"available"];
[[self xmppStream] sendElement:presence]; 

But at the end where [email protected] is logged in following method is NOT being invoked

- (void)xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence
{
    NSLog(@"---------- xmppStream:didReceivePresence: ----------");
}

What might be the issue?


Solution

  • The reason presence was not being sent is that code was incorrect. I used following code to send presence

    XMPPPresence *presence = [XMPPPresence presence];
        [[self xmppStream] sendElement:presence]; 
    

    after that it showed user online on openfire server and message was correctly being sent to other users.