Im developing an app that have to download multiple files. I have no problems when the app is in foreground.
To continue the download when app is in background i'm using the following code (from iOS Background downloads when the app is not active):
self.backgroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ [[UIApplication sharedApplication] endBackgroundTask:self.backgroundTask]; self.backgroundTask = UIBackgroundTaskInvalid; }]; /* Here your downloading Code, let say getDataFromServer method */ [self getDataFromServer]; // Its dummy method /* Your downloading Code End Here */ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ [[UIApplication sharedApplication] endBackgroundTask:self.backgroundTask]; self.backgroundTask = UIBackgroundTaskInvalid; });
This code is ok until the device screen is on. But when the device goes into standby, something happens and download stops. Probably ios closes active internet connections of my background process.
Is there a way in IOS 6 and 7 to keep the connection alive during standby?