0

I have a local node.js server which has some new data every few seconds and also i have a iPhone app by using which right now i am able to get the JSON data from server and able to display it in my application.

But in current process user has to hit a option to get the data from server but i want to hit the server every 30 seconds automatically without user interaction and if any new data is there i want to get the data and display it.

So what is the best way to do this ? Also is there any iOS Library is there which will help me to do this?

user1227928
  • 831
  • 1
  • 12
  • 27
  • How about using websockets instead, sending the data from the server when it's actually available, no hitting neccessary – adeneo Feb 25 '15 at 20:09
  • You could call whatever method starts your connection from an NSTimer's action method. You would want to make sure your users know this is happening, because it could use a lot of battery and cellular time. – rdelmar Feb 25 '15 at 20:20

1 Answers1

0

You don't have to use websockets or other push technologies in a simple app that refreshes data every 30 seconds. But consider using HTTP cache revalidation to reduce network traffic.

Use repeating NSTimer and make sure to break retain cycles.

Community
  • 1
  • 1
kean
  • 1,561
  • 14
  • 22