0

My app is crashing because of the auto-lock setting time is 2 min and my web-serevice is taking time more than 2 min. if time goes over 2 min then my app crashed every time.

but i don't want to set the auto-lock time to 15 min or never from setting. I want some solution within the app without changing the setting value.

please let me know if any one know the solution to avoid the crash.

Thanks you.

uttam
  • 1,364
  • 4
  • 20
  • 35
  • 2 min for a request is very high time... Can't you try to split it into different call? (Another thing: I don't know you application, but if an application "freeze" for 2 min I close it.) – Marco Pace Dec 15 '11 at 14:16
  • In my app,I have to fetch large size of data using some web-servies.and it is taking more time than normal.I can not split it into different call.but can you please tell me how I can close my app after some fix time. – uttam Dec 15 '11 at 14:22

2 Answers2

3

You can turn off auto-lock temporarily until the request is completed, that is set [UIApplication sharedApplication].idleTimerDisabled to YES.

The other option is to set your web service request up as a finite-length task running in background, so even if your device goes to sleep, the request keeps running. Watch out for the 10-minute time limit though.

Either way, when running in foreground, make sure the request is done asynchronously and doesn't block the main thread or your app will always get killed after doing that for too long.

macbirdie
  • 16,086
  • 6
  • 47
  • 54
1

How about detecting when your app goes into background / inactive

- (void)applicationWillResignActive:(UIApplication *)application

and use the task completion mechanism - take a look at this question: How to implement Task completion

As a side note, there is a 10 minutes limit to complete the background task (you get a warning) - otherwise your app will get terminated.

Did you consider splitting the data into smaller chunks and keep track of the progress?

Community
  • 1
  • 1
Paul Ardeleanu
  • 6,620
  • 2
  • 40
  • 41