When I force my device to go to sleep by pressing the power button, my background task stops by calling the didCompleteWithError delegate didCompleteWithError with an error:
The operation could not be completed. Operation not allowed
How to configure my NSURLSession to continue booting even in sleep mode?
Is it possible? If not, what are my options? I need to download a 300 MB file, so when the connection is low, the application will go into sleep mode until the end of the download.
Here is the creation of my session:
static NSURLSession *backgroundSession; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ backgroundSession = [NSURLSession sessionWithConfiguration: [NSURLSessionConfiguration backgroundSessionConfiguration: @"com.myapp.mytask"] delegate:self. myDelegate delegateQueue:self.myQueue]; }); NSURLSessionDownloadTask *task = [backgroundSession downloadTaskWithRequest: self.urlRequest]; [task resume];
source share