Skip to content

[Feature] Background downloads on iOS and Android (URLSession background, foreground service), with pinned TLS #452

Open

Description

@houko

Context

On iOS and Android, an app's net/http transfers stop when the app goes to the background: iOS suspends the process, and Android may stop it. Apps that download large files (Kando's phone app downloads films of several GB from the desktop) need the system's background transfer services: URLSession with a background configuration on iOS (the system keeps downloading and relaunches the app when done), and on Android a foreground service of type dataSync or WorkManager with setForeground, showing a notification with progress. Kando keeps the screen on while downloading as a workaround, which does not survive leaving the app.

Proposal

A download service: Download(cx, req, dest, opts) returning a handle with progress, pause/resume (Range), cancel, and completion delivered on the engine's goroutine, which continues in the background (iOS background URLSession, Android foreground service with a progress notification, the desktops in-process), survives the app being suspended, and reports downloads that finished while the app was not running when it starts again. Custom TLS trust (a pinned certificate) is needed for LAN servers with self-signed certificates.

Acceptance

  • On iOS and Android, a 2 GB download continues after the app is backgrounded and completes; progress resumes when the app comes back; a pinned self-signed server works.

Activity

  1. self-assigned this
    on Nov 20, 2026
  2. houko commented on Nov 20, 2026

    @houko
    CollaboratorAuthor

    Reviewed against the current platform architecture. This is a substantial cross-platform service, not a focused bug fix: iOS background URLSession requires delegate persistence and relaunch handoff, Android needs a foreground dataSync service or WorkManager plus notification permission and progress transport, and both need durable download state, range resume, cancellation, pinned TLS, and engine-goroutine delivery after relaunch. No existing core/driver service boundary covers this lifecycle. I am leaving the issue open for a dedicated download-service design rather than opening a partial API that cannot satisfy the acceptance criteria.

  3. houko commented on Nov 22, 2026

    @houko
    CollaboratorAuthor

    I audited #452 against the current platform contracts and extended the existing Android implementation to Apple and macOS in PR #1678.

    The shared core.Scope.Download API now has durable task state, progress, pause/resume, cancellation, atomic publication and terminal replay. Android retains its foreground dataSync service. iOS uses grouped background URLSession sessions with launch reconnect, native resume data, journal recovery after container moves and exact certificate pin validation. macOS uses the same host with an in-process session. The public docs explain the Apple ATS requirement for self-signed endpoints.

    Verification included Apple target checks, native publication and trust tests, a signed iPhone 2 GiB transfer that continued after the Go process exited and replayed after relaunch, and rejection tests that preserved prior destination files. Windows and Linux transfer hosts remain in the roadmap, so the issue stays open for those targets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions