Skip to main content
All posts
$less posts/ios-background-downloads-done-right.txt
posts/ios-background-downloads-done-right.txt0 min

iOS Background Downloads Done Right

author Nikita Pochaevdate Oct 2025category iOS

Background downloads on iOS are deceptively complex. URLSession’s background configuration handles the heavy lifting, but the edge cases will get you.

The basics

Create a URLSession with a background configuration. The system manages the download even if your app is suspended or terminated. When the download completes, the system relaunches your app to handle it.

Edge cases that bit us

  • Downloads resuming after app update (session identifier must be stable)
  • Cellular vs WiFi policy changes mid-download
  • Disk space running out during download
  • User revoking background app refresh permission

Our architecture

We built a DownloadManager that wraps URLSession and provides:

  • Progress tracking via Combine publishers
  • Automatic retry with exponential backoff
  • Queue management (max 3 concurrent downloads)
  • Persistent download state in CoreData

The key insight: treat the download manager as infrastructure, not a feature. It should be boring and reliable.

#iOS#Swift
up 47d 6h 23mload 1.47 1.22 0.98tasks 406thr 1,247mem 37%
interactive shell -- try: help, ls posts/, cat meridian, open blog, neofetch
po4yka@ghostty:~$

© Nikita Pochaev · built with ghostty vibes