NSURLErrorDomain Code=-997 "Lost connection to background transfer service"

My error was that I used a dataTaskWithRequest instead of uploadtaskWithRequest or in your case downloadtaskWithRequest. Obviously a datatask can't run in the background and get's killed.


What version of the SDK are you on? There was a bug in the background transfer daemon that could cause it to crash, which has since been fixed. I would download the latest Xcode beta and try it again.


Probably Background Transfer daemon crashed. Try to check crash logs on your device. May be you will find something interesting there.