I'm having a strange issue with NSURLSession on the delegate method didFinishDownloadingToURL.
First thing I'm doing is check if the temporary downloaded file exist:
- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask
didFinishDownloadingToURL:(NSURL *)location
{
if (![[NSFileManager defaultManager] fileExistsAtPath: [location path]])
{
NSLog(@"Error. File not found");
return; // is giving error when the app is wake up by the system
}
...
}
It works normally when the app is in foreground and download finishes. But when the app is in background and is killed forcedly by the operating system, it returns false.
Does anyone have any idea about what might be happening? I know that there is a time limit for the execution of this delegate method when the app is wake up by the operating system, by it makes no sense for the temporary file to be not there. I can't even copy it to another location... Does it make sense to be because of the size of the file? I'm downloading a file of +-130MB.
Thanks.