When your app is moved to the background, the system will typically suspend it. And once your app is suspended the system may reclaim resources from your network connections, which essentially tears those connections. You can read Technote 2277 Networking and Multitasking for more details about this.
How best to deal with this depends on type of requests:
For short-running requests you can use a
UIApplication
background task to prevent your app from being suspended on moving to the background.Note
UIApplication
background tasks can be a bit tricky. See my UIApplication Background Task Notes post for some hints and tips.If you’re dealing with a long-running request — for example, downloading a large file — you should use an
NSURLSession
background session so that the system can continue the work even if your app gets suspended.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"