0

When iPhone app is in background state or when app is minimized, I want to monitor the duration of time the app is in background and on every regular interval like every 24hrs need to get updates from web server and write the modifications in my local database.

This monitor cycle will repeat as long as app is in background. Is this kind of task is possible in iPhone applications ? Could any body help me how can I perform these tasks when app is in background state ?

beginBackgroundTaskWithExpirationHandler: is the API to make the app in background for long tasks but how long will this support.

Srivathsa
  • 606
  • 10
  • 34

1 Answers1

0

Background tasks are killed after 10 minutes time, so to answer your question: No, it's not without faking some kind of long term event handling through a significant location's update, and even then, you have no control over when exactly the events are sent. On the other hand, using APNS to alert the user to a change has the possibility of being ignored, but comes with regularity.

CodaFi
  • 43,043
  • 8
  • 107
  • 153
  • Hi Thanks for quick response. You mean to say APNS will solve my purpose ? Please share me details that is suitable in my case. – Srivathsa Dec 11 '12 at 07:37
  • No, APNS will not solve it. As I stated in the answer, though you can (but shouldn't), post a push notification every 24 hours, it is impossible to know whether the user will immediately, if at all, act on it and bring your app to the forefront. Besides, what's the point in downloading daily updates? Just cache like mad, then grab the latest changes when the app is reopened. – CodaFi Dec 11 '12 at 07:39
  • My Database web server contains set of metrics for different Geographic regions. Server will have daily updates, weekly updates, monthly updates.. This is the clear details of my requirement. So in this scenario server sends a push notification when ever there are updates and my app can download the same i guess. Could you plz tell me now whether it solves my purpose.. – Srivathsa Dec 11 '12 at 07:45
  • Sure, like I said above, you can APNS all you like, but that doesn't stop people from just turning it off or ignoring it. If you want to go about this reliably, ignore real time updates and focus on synchronizing the database and the client. – CodaFi Dec 11 '12 at 07:47