iOS NSURLSessionDelegate [URLSession: task: didCompleteWithError:] returns with error if app is suspended
I'm writing an app that requires background downloading. I've configured my NSURLSession to be in the background Session Configuration.
Everything is working when the app is in foreground or even in background mode (home button), but as soon as I press the power button to force the phone into sleep mode. The NSURLSession delegate call:
- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error
returns with a Error Domain=NSPOSIXErrorDomain Code=1 "The operation couldn’t be completed. Operation not permitted" and my download fails.
You have forgotten the bg-download entitlements (see target -> capabilities)