Daily iOS
Networking

Background session completion

A large file is downloading through a background URLSession and the app gets terminated completely (by the system, not a swipe up). When the download finishes, what exactly has to happen in the app, in what order, so you don't lose the file?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

The system relaunches the app in the background, handleEventsForBackgroundURLSession in the AppDelegate stores the completionHandler and recreates the session with the same identifier, the delegate's didFinishDownloadingTo moves the file immediately, and didFinishEvents calls the stored handler.

Share a question