---
title: BADownloadManager
framework: backgroundassets
role: symbol
role_heading: Class
path: backgroundassets/badownloadmanager
---

# BADownloadManager

An object that manages the queue of scheduled asset downloads.

## Declaration

```swift
class BADownloadManager
```

## Overview

Overview Use BADownloadManager to schedule and cancel asset downloads, monitor their progress, and access the queue of pending downloads. You don’t create instances of this class directly; instead, use the shared property to access the framework’s singleton that it shares between your app and the app’s extension. Because the download manager is a shared resource, prevent race conditions by using the withExclusiveControl(_:) and withExclusiveControl(beforeDate:perform:) methods to assume absolute control of the manager before you schedule asset downloads or manipulate those already in the manager’s queue. To respond to asset download events and process concluded downloads, create a type that conforms to the BADownloadManagerDelegate protocol and assign an instance of it to the download manager’s delegate property. The following example shows how to create an asset download, acquire exclusive control of the shared download manager, and then use the manager to schedule the download: let url = URL(string: "https://cdn.example.com/level-resources.zip")! let request = URLRequest(url: url) let identifier = "group.com.example.my-game"

// Create an asset download. let download = BAURLDownload(identifier: "level-resources",                              request: request,                              applicationGroupIdentifier: identifier)

// Access the shared download manager. let manager = BADownloadManager.shared

// Assign the manager's delegate so the framework can notify // the app of asset download events. manager.delegate = self

do {     // Attempt to acquire exclusive control of the manager.     manager.withExclusiveControl { error in         // Return immediately if that attempt fails.         if let error {             print(error.localizedDescription)             return         }                  // Use the manager to schedule the asset download.         try manager.schedule(download)     } } catch {     // Handle the error.     print(error.localizedDescription) }

## Topics

### Accessing the download manager

- [shared](backgroundassets/badownloadmanager/shared.md)

### Managing downloads

- [scheduleDownload(_:)](backgroundassets/badownloadmanager/scheduledownload(_:).md)
- [startForegroundDownload(_:)](backgroundassets/badownloadmanager/startforegrounddownload(_:).md)
- [cancel(_:)](backgroundassets/badownloadmanager/cancel(_:).md)

### Monitoring downloads

- [delegate](backgroundassets/badownloadmanager/delegate.md)
- [BADownloadManagerDelegate](backgroundassets/badownloadmanagerdelegate.md)

### Fetching in-progress downloads

- [fetchCurrentDownloads()](backgroundassets/badownloadmanager/fetchcurrentdownloads().md)
- [fetchCurrentDownloads(completionHandler:)](backgroundassets/badownloadmanager/fetchcurrentdownloads(completionhandler:).md)

### Synchronizing manager access

- [withExclusiveControl(_:)](backgroundassets/badownloadmanager/withexclusivecontrol(_:).md)
- [withExclusiveControl(beforeDate:perform:)](backgroundassets/badownloadmanager/withexclusivecontrol(beforedate:perform:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Unmanaged asset downloads

- [Configuring an unmanaged Background Assets project](backgroundassets/configuring-an-unmanaged-background-assets-project.md)
- [Downloading essential assets in the background](backgroundassets/downloading-essential-assets-in-the-background.md)
- [BAManifestURL](bundleresources/information-property-list/bamanifesturl.md)
- [BAInitialDownloadRestrictions](bundleresources/information-property-list/bainitialdownloadrestrictions.md)
- [BAEssentialMaxInstallSize](bundleresources/information-property-list/baessentialmaxinstallsize.md)
- [BAMaxInstallSize](bundleresources/information-property-list/bamaxinstallsize.md)
- [BADownloaderExtension](backgroundassets/badownloaderextension-qwaw.md)
- [BADownloaderExtensionConfiguration](backgroundassets/badownloaderextensionconfiguration.md)
- [BAURLDownload](backgroundassets/baurldownload.md)
- [BADownload](backgroundassets/badownload.md)
