views:

648

answers:

3

Hello,

I want to create a chat sort of application on the iphone. I know how I would go about implementing a poll model, where the iphone would poll the server to see if any messages have arrived and if they have it can retrieve them and show them to the user. However im more intersted in a push model, where the server pushes new messages to the iphone and it displays it to the user. The part im having a hard time figuring out is how to go about opening some permanent connection on the phone that will listen for incoming messages...Any suggestions or comments would be appriciated..

Thanks

Daniel

A: 

You could do this with http if you wanted to make it that simple.

RHicke
i got a service that you communicate w ith through http, but the connection is not persistent, right now i dont know of a way to go from the service directly to the iphone with out having the iphone initiate the request..
Daniel
You're going to need to have a socket open between the iphone and your server. I developed a browser based chat at work. i did it by polling every 6 seconds it works fine. So either that or write a socket in Objective-C
RHicke
yea doing i t by polling is easy...i want to explore doing it by pushing
Daniel
A: 

The iPhone 3 SDK has push support built in. Basically, all messages that need to be pushed (from all apps) go to Apple's server, which maintains a persistent connection to the user's iphone. The upside is that you dont have to worry about it and your app can get updates even when its not running (so like, from the home screen). The downside is that your data has to go through Apple's server.

Alex
this is not really for that purpose tho, the purpose of push notification is that people can still can m essages when the app is not running
Daniel
A: 

Answer to this is: Use sockets

Daniel