I am using NSURLSession to download some mp3 files and store them in the device. Everything works fine but sometimes out of the blue, the app crashes and i get this weird error saying NSURLErrorDomain Code=-997 "Lost connection to background transfer service"
. It does not happen alot but when it does it just messes up the whole app, like when i launch the app the next time all the download tasks are messed up and i just have to rebuild the application on the device to get it to work again.
Note that i only get this error since using Xcode 6 and ios8, even though I'm not sure its is related to ios8 or not.
This is the complete error description:
Error Domain=NSURLErrorDomain Code=-997 "Lost connection to background transfer service" UserInfo=0x178664100 {NSErrorFailingURLKey=http://XXXXXXXXXX.mp3, NSLocalizedDescription=Lost connection to background transfer service, NSErrorFailingURLStringKey=http://XXXXXXXXXXX.mp3}
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.