I know that on iOS 4, the Wi-Fi connection used to be persistent, so going into sleep mode/locked kept the connection ON .
This was modified in the next version iOS 5 to improve battery life.
In iOS 5 , requiring the device to be plugged into a power source in order to have a persistent Wi-Fi connection.
Wi-Fi connection is disconnecting automatically after iPad is going into sleep mode/locked .
Here comes my problem, I'm sending a bulk chunk of data through WiFi which may take too much time. So the user have to wait up to the transaction complete.
iPad may switch into sleep mode/locked while sending process took more time which will result the WiFi connection error.
Now i have set the UIRequiresPersistentWiFi to YES in info.plist. However same network issue happened again.
I would like to keep/persistent the WiFi Connection active even iPad is going into sleep mode/locked in iOS5. So is there any alternatives to achieve this.
Thanks.
Phew... Finally I got a solution with idleTimerDisabled
.
Its a Boolean value that controls whether the idle timer is disabled for the application .
Its the way to prevent the iPad from sleeping while my application is running.
The default value of this property is NO
. When most applications have no touches as user input for a short period, the system puts the device into a "sleep
” state where the screen dims.
This is done for the purposes of conserving power. However, applications that don't have user input except for the accelerometer—games, for instance—can, by setting this property to YES
, disable the “idle timer
” to avert system sleep.
I just set the value to YES
while I'm sending a bulk chunk of data through WiFi and have set the value to NO
when the process is completed.
Example:[[UIApplication sharedApplication] setIdleTimerDisabled:YES];
Note: Be sure to reset this property to NO when your app does not need to prevent screen locking.
You can see more details here
This is because of how iOS handles Wi-Fi connections. What's happening is that the iPad is going into sleep mode (this happens after 5 minutes of inactivity). This mode was designed to improve battery life. On iOS 4, the Wi-Fi connection used to be persistent, so going into sleep mode kept the connection on (or switching to cellular data). This was modified in the next version, iOS 5, requiring the device to be plugged into a power source in order to have a persistent Wi-Fi connection.
I just saw this question, and considering the date, I don't know whether this still helps, but have you tried using UIApplication
's beginBackgroundTaskWithExpirationHandler:
method?
You can do something along the lines of:
//#1 - Start a chunk of work as able to run in the "background"
UIApplication *app = [UIApplication sharedApplication];
bgTask_ = [app beginBackgroundTaskWithExpirationHandler:^{
if (bgTask_ != UIBackgroundTaskInvalid) {
//cancel the connection/load/chunk of work/operation
[self cancelLoad];
[[UIApplication sharedApplication] endBackgroundTask:bgTask_];
bgTask_ = UIBackgroundTaskInvalid;
}
}];
//#2 - Do work...
//#3 - Once work is finished, Explicity finish the background task
UIApplication *app = [UIApplication sharedApplication];
if (bgTask_ != UIBackgroundTaskInvalid) {
[app endBackgroundTask:bgTask_];
bgTask_ = UIBackgroundTaskInvalid;
}
You can call #3 in another method as well, since you might be performing asynchronous operations (which run in the background and asynchronously call messages). You can also check up documentation on the 'beginBackgroundTaskWithExpirationHandler:` on the official docs for detailed information.
Hope this helps! :)