getDiagnosisKeys(completionHandler:)
Requests the temporary exposure keys from the user’s device to share with a server.
Declaration
func getDiagnosisKeys(completionHandler: @escaping @Sendable ([ENTemporaryExposureKey]?, (any Error)?) -> Void)func diagnosisKeys() async throws -> [ENTemporaryExposureKey]Parameters
- completionHandler:
The completion handler that the framework calls when Getdiagnosiskeys(completionhandler:) completes. If the method completes successfully,
keyswill contain the diagnosis keys for this device anderrorwill benil. If it fails,keyswill benilanderrorindicates the reason it failed.
Discussion
The app must be in the foreground when it calls this method. Each time the app calls this method, the system presents an interface that requests authorization.
When ENAPIVersion is set to 1 in the app’s Info.plist file, you must wait approximately 24 hours after the first call of getDiagnosisKeys(completionHandler:) before this call returns a valid key. To test your app without waiting 24 hours, use getTestDiagnosisKeys(completionHandler:).
When ENAPIVersion is set to 2, this call returns a diagnosis key with a shortened rolling period.