<!--
{
  "availability" : [
    "iOS: 16.1.0 -",
    "iPadOS: 16.1.0 -",
    "macCatalyst: 16.1.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 18.4.0 -",
    "visionOS: 2.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "BackgroundAssets",
  "identifier" : "/documentation/BackgroundAssets/BADownloadManagerDelegate/download(_:didReceive:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Background Assets"
    ],
    "preciseIdentifier" : "c:objc(pl)BADownloadManagerDelegate(im)download:didReceiveChallenge:completionHandler:"
  },
  "title" : "download(_:didReceive:completionHandler:)"
}
-->

# download(_:didReceive:completionHandler:)

Tells the delegate to resolve the specified URL authentication challenge.

```
optional func download(_ download: BADownload, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping @Sendable (URLSession.AuthChallengeDisposition, URLCredential?) -> Void)
```

```
optional func download(_ download: BADownload, didReceive challenge: URLAuthenticationChallenge) async -> (URLSession.AuthChallengeDisposition, URLCredential?)
```

## Parameters

`download`

The associated asset download.

`challenge`

An object that provides the information you need to decide how to respond to the server’s request for authentication.

`completionHandler`

The completion handler you call to tell the system how to respond to the challenge.

## Discussion

The completion handler takes the following parameters:

- An <doc://com.apple.documentation/documentation/Foundation/URLSession/AuthChallengeDisposition> that indicates whether the system processes, cancels, or rejects the challenge.
- If the specified dispostion is <doc://com.apple.documentation/documentation/Foundation/URLSession/AuthChallengeDisposition/useCredential>, the <doc://com.apple.documentation/documentation/Foundation/URLCredential> to use for authentication; otherwise, specify `nil`.

If you implement this method, make sure to call the completion handler promptly and with the necessary information. Otherwise, the server may deny the request and the associated asset download fails.

For more information about authentication challenges, see <doc://com.apple.documentation/documentation/Foundation/handling-an-authentication-challenge>.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)