ikevin8me
ikevin8me

Reputation: 4313

RobbieHanson's XMPPFramework didReceiveMessage not called

I'm developing on iOS and using Robbie Hanson XMPPFramework. The method didReceiveMessage is never called.

I did successfully connect, and sent 'presence' (confirmed by using NSLog. That can be confirmed by the Openfire admin panel which shows the user as green and connected.

    XMPPPresence* presence = [XMPPPresence presence]; // type="available" is implicit
[[self xmppStream] sendElement:presence];

Further, I received didReceiveIQ calls. I do not know what is IQ and do I need to handle it?

The most important thing is do I make didReceiveMessage get called. Thanks!

Upvotes: 2

Views: 1661

Answers (2)

Andres
Andres

Reputation: 11747

One thing to have in mind is that after authentication you need to send a presence otherwise you won't receive any message.

Read the following blog post: Build a complete iOS messaging app using XMPPFramework - Tutorial Part 1

After a sucessfull connection, you are not going to receive any <message/> until you make yourself available sending the previous presence. <presence/>

You should have something like this somewhere in your code:

func xmppStreamDidAuthenticate(_ sender: XMPPStream!) {
    self.xmppStream.send(XMPPPresence())
    print("Stream: Authenticated")
}

If you take a look to the second part of the tutorial I posted you will see how to perform the authentication and everything:

Build a complete iOS messaging app using XMPPFramework - Part 2

Upvotes: 1

AdonisDee
AdonisDee

Reputation: 60

The didReceiveMessage delegate will only be called if your client receives a message stanza like this:

<message xmlns="jabber:client" from="[email protected]" to="[email protected]" id="21" type="chat"><body>This is a sample message.</body></message>

This stanza is received if other XMPP clients send you a chat message. If your didReceiveIQ is already being called then we can assume that we have setup our delegates properly.

Upvotes: 0

Related Questions