Best way to receive new messages in a IM style app

At the moment I am just querying the server every 3 seconds to see if there are any new messages using an NSURLRequest and such. If there are it saves them to the database and sends an NSNotificationCenter notification if there aren't then it just waits 3 seconds and tries again.

Is this the best way to do it? I realise (form posts on here and information elsewhere) that opening a persistant connection to the server is tedius and not reccommended, so would this be the best way to do it?

My main worry is that if there are no new messages its downloading an empty (of information, but still a few bytes big) XML feed, and running this every 3 seconds is going to add up eventually and use a lot of data.

Any pointers would be much appreciated.



XMPP would do this with a long-living TCP connection. How about using an XMPP service?

Need Your Help

Google Maps marker not showing at all google-maps

I developed many websites using the same google maps code, but this time my marker is not showing and I can't figure out why.

Scala difference between “+:” and “::”


I am reading a scala book and they use two different type of cons operators when doing pattern matching on sequences and lists