Idle Timer and Network

One of the problems that I stumble upon was when doing long network operations on the IPhone, like downloading a big file, the operation never ended with success.

The download always failed with an IO problem, after some investigation I found out that the problem was the battery saver of the IPhone.

The thing is that when you don’t interact with an aplication after some minutes the IPhone will enter in a battery save mode, first it will dim the screen and after some time it will turn off the screen and disable any wi-fi or 3g connections.

To avoid this you must disable the idle timer on the application when doing long network operations. There is a simple property on the UIApplication class called IdleTimerDisabled. Just do this on your code:

   [UIApplication sharedApplication].idleTimerDisabled = YES;
   // do long network operation
   [UIApplication sharedApplication].idleTimerDisabled = NO;

Posted

in

by

Tags:

Comments

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: