nemesis
nemesis

Reputation: 1351

Using XMPP Framework for iOS: Receiving presence when a subscriber becomes available/unavailable

I'm trying to implement some of the delegate methods of the XMPPStream class, one of which is xmppStream:(XMPPStream *)sender didReceivePresence:(XMPPPresence *)presence. I have two users registered, and both are subscribed to each other's presence notifications. A thing I noticed is, the didReceivePresence method is called only when a user authorizes. Disconnecting and/or connecting a user doesn't notify the subscriber about it. What can I do to receive the notifications when someone I'm subscribed to goes offline/online? The code I use to send presence to the XMPPStream is:

- (void) goOnline
{
    XMPPPresence *presence = [XMPPPresence presence];
    [_stream sendElement:presence];
}

- (void) goOffline
{
    XMPPPresence *presence = [XMPPPresence presenceWithType:@"unavailable"];
    [_stream sendElement:presence];
}

Upvotes: 2

Views: 1280

Answers (1)

nemesis
nemesis

Reputation: 1351

Actually my setup was correct, but I wasn't subscribed to the user's presence notifications, I thought that if he was in my roster I'd get this notifications automatically. Don't forget that you have to accept the presence subscription request by using the acceptPresenceSubscriptionRequestFrom method. If you receive a subscription request, the user automatically is added to your roster, and you are added to his roster, but both of you won't receive presence messages until you don't accept the subscription request.

Upvotes: 3

Related Questions