<!--
{
  "availability" : [
    "iOS: 14.4.0 - 27.0.0",
    "iPadOS: 14.4.0 - 27.0.0",
    "macCatalyst: 14.4.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "ExposureNotification",
  "identifier" : "/documentation/ExposureNotification/ENManager/preAuthorizeDiagnosisKeys(completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Exposure Notification"
    ],
    "preciseIdentifier" : "c:objc(cs)ENManager(im)preAuthorizeDiagnosisKeysWithCompletionHandler:"
  },
  "title" : "preAuthorizeDiagnosisKeys(completionHandler:)"
}
-->

# preAuthorizeDiagnosisKeys(completionHandler:)

Allows users to authorize a one-time release of diagnosis keys within five days of the authorization.

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

```
func preAuthorizeDiagnosisKeys() async throws
```

## Parameters

`completionHandler`

The completion handler the framework calls when the method completes.

## 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:
> 
> ```swift
> func preAuthorizeDiagnosisKeys() async throws
> ```
> 
> For information about concurrency and asynchronous code in Swift, see <doc://com.apple.documentation/documentation/Swift/calling-objective-c-apis-asynchronously>.

> Important:
> Before requesting authorization, ensure the application is in the foreground.

This method prompts the user when getting tested to share their diagnosis keys if they receive a positive test result. An app should only call this method if it has a way to determine that the user is about to take a COVID test, such as apps that allow users to schedule testing appointments, and that can also determine if the result is positive.

The authorization duration is five days.

---

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)