download

fun download(taskId: String, url: String, onComplete: (localPath: String) -> Unit? = null, onError: (Exception) -> Unit? = null)

Schedules a background download via NSURLSession.

The download is handed off to the iOS OS daemon immediately. Even if your app is killed, the download continues. iOS wakes your app (or calls the background completion handler) when the file is ready.

Parameters

taskId

Unique identifier for this download. Used in TaskMonitor.

url

The URL to download from.

onComplete

Called with the local file path when the download finishes.

onError

Called with the error if the download fails.