---
title: "download(_:didReceive:completionHandler:)"
framework: backgroundassets
role: symbol
role_heading: Instance Method
path: "backgroundassets/badownloadmanagerdelegate/download(_:didreceive:completionhandler:)"
---

# download(_:didReceive:completionHandler:)

Tells the delegate to resolve the specified URL authentication challenge.

## Declaration

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

```swift
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

Discussion The completion handler takes the following parameters: An URLSession.AuthChallengeDisposition that indicates whether the system processes, cancels, or rejects the challenge. If the specified dispostion is URLSession.AuthChallengeDisposition.useCredential, the 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 Handling an authentication challenge.

## See Also

### Reacting to download events

- [downloadDidBegin(_:)](backgroundassets/badownloadmanagerdelegate/downloaddidbegin(_:).md)
- [download(_:didWriteBytes:totalBytesWritten:totalBytesExpectedToWrite:)](backgroundassets/badownloadmanagerdelegate/download(_:didwritebytes:totalbyteswritten:totalbytesexpectedtowrite:).md)
- [downloadDidPause(_:)](backgroundassets/badownloadmanagerdelegate/downloaddidpause(_:).md)
