1

I would like to know what is the best method to get data in iPhone as soon as a user entered or modified data in server. I can send a request for a small time interval to server to check any modifications done in server(Like Polling). I know it is very awkward. Pleas suggest a best one !!!

EDIT

I am not talking about push notifications. I need some Data something like while having a cricket match, when each time score updates in server I need to get that data (via XML,JSON, or any other medium) in my iPhone.

McGarnagle
  • 101,349
  • 31
  • 229
  • 260
rakeshNS
  • 4,227
  • 4
  • 28
  • 42
  • Finally got answer from http://stackoverflow.com/questions/337985/comet-server-push-to-client-on-iphone and http://stackoverflow.com/questions/1589816/iphone-real-time-notification-from-a-server-without-using-apple-push-notificati – rakeshNS Apr 11 '12 at 11:03

2 Answers2

2

You're talking about push notifications: http://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html

These let you send specific messages from your server, to devices that opt in to receiving push notifications from your app.

McGarnagle
  • 101,349
  • 31
  • 229
  • 260
  • can i use push notification for passing huge amount of data continuously? – rakeshNS Apr 11 '12 at 09:58
  • @rakeshNS, no, I don't think that's what they're designed for. Not sure long polling is ideal either. Have you looked into peer-peer? Looks like iphone supports it: http://support.apple.com/kb/HT3621 – McGarnagle Apr 11 '12 at 10:02
1

What you are looking for is known as "Push Technology" (there are several variations of the same idea). In your case, what I think is best suited is "long polling". In short:

  1. you poll specifying a very long timeout;
  2. the server will not reply until it has some new data, so your request will be kept open as long as timeouts allow;
  3. as soon as the server has got new data, it will reply, and you get the changes immediately;
  4. when the timeout expires, you send a new request.

The fact of having a long poll will reduce the overhead you are worried about with "short" polling. Indeed, with short polls the idea is sending frequent requests, with a very short round-around time. This will make you send constantly requests to check for new data. With long polling you send a request only when you have got new data, or when a timeout fires (which can be several minutes).

In this S.O. post, you will find a way to implement it.

Community
  • 1
  • 1
sergio
  • 68,819
  • 11
  • 102
  • 123
  • 1
    Push notifications are better suited to a mobile device as they will use less battery than performing long polling. – Nick Bull Apr 11 '12 at 09:24