I have to download a long list of files and so all these operations may take a long time. I decided to manage these download tasks with a NSURLSession instantiated using a background configuration. Once built and ran the code onto my iPhone I try to test the application unplugging the device and launching the app without xCode. In that situation I notice that downloads no longer start if connection is not via WiFi. Moreover I notice that, during download operations, if the device goes into sleep mode, unlocking it after few seconds (10-15 seconds) app will be relaunched and downloads were stopped. I don't know if it is important but I hope that those issues not existed in iOS 8.2 (now I'm using iOS 8.3).
My session configuration is as follow
NSString *sessionIdentifier = @"com.yourappfor.example";
NSURLSessionConfiguration *sessionConfiguration;
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) {
sessionConfiguration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:sessionIdentifier];
} else {
sessionConfiguration = [NSURLSessionConfiguration backgroundSessionConfiguration:sessionIdentifier];
}
[sessionConfiguration setAllowsCellularAccess:YES];
[sessionConfiguration setSessionSendsLaunchEvents:YES];
[sessionConfiguration setURLCache:nil];
[sessionConfiguration setDiscretionary:YES];
[sessionConfiguration setTimeoutIntervalForRequest:90.0];
[sessionConfiguration setTimeoutIntervalForResource:43200.0];
[sessionConfiguration setHTTPMaximumConnectionsPerHost:15];
NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfiguration delegate:self delegateQueue:nil];