---
title: "requestPreAuthorizedDiagnosisKeys(completionHandler:)"
framework: exposurenotification
role: symbol
role_heading: Instance Method
path: "exposurenotification/enmanager/requestpreauthorizeddiagnosiskeys(completionhandler:)"
---

# requestPreAuthorizedDiagnosisKeys(completionHandler:)

Requests diagnosis keys after the user authorizes sharing them.

## Declaration

```swift
func requestPreAuthorizedDiagnosisKeys(completionHandler: @escaping @Sendable ((any Error)?) -> Void)
```

```swift
func requestPreAuthorizedDiagnosisKeys() async throws
```

## Parameters

- `completionHandler`: The completion handler the framework calls when the method completes.

## Discussion

Discussion important: You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration: func requestPreAuthorizedDiagnosisKeys() async throws For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously. If the user authorizes sharing of diagnosis keys and receives a positive test result within five days, call this method to retrieve the preauthorized keys, but only after informing the user of the positive result. ENDiagnosisKeysAvailableHandler receives the keys when the user unlocks their device. Subsequent calls to this method have no effect. If more than five days pass after the user authorizes sharing of their keys, or if the user declines to share their keys, the completion handler returns an error. important: Your app must notify a user when their diagnosis keys are shared. The language of the notification must remind the user that they authorized the sharing of their diagnosis keys.  For example: “In accordance with your prior decision to share your keys if your test result was positive, your keys are now being shared with [PHA].”

## See Also

### Preauthorizing Exposure Keys

- [preAuthorizeDiagnosisKeys(completionHandler:)](exposurenotification/enmanager/preauthorizediagnosiskeys(completionhandler:).md)
- [ENDiagnosisKeysAvailableHandler](exposurenotification/endiagnosiskeysavailablehandler.md)
- [diagnosisKeysAvailableHandler](exposurenotification/enmanager/diagnosiskeysavailablehandler.md)
