Passkeys implementation: presentationContextProvider

Hi! 👋

Recently, we added the passkeys feature to our SPM package/demo application. We based our solution on the Apple's sample implementation.

However, after some time, we noticed that the ASAuthorizationController.presentationContextProvider configuration is not required. Moreover, the ASAuthorizationControllerPresentationContextProviding.presentationAnchor(for:) method never gets called.

We're wondering if there are any unwanted side effects that could be caused by removing this part of the code. We were not able to find any, as everything works the same way as before we removed the presentationContextProvider-related code. However, we're guessing that there must be a good reason why it is included in the demo app 🤔

Also, we're curious about how it works under the hood. Does it use the currently visible UIWindow by default?

Accepted Reply

Glad to hear you're adopting passkeys! If and when the context provider is invoked varies by platform and OS version. It used to get called on iOS only when we felt we needed more context about where to position the sheet. On more recent versions of iOS, iPadOS, and Catalyst, it should get called every time. While we can make good guesses in some scenarios, there are situations where we can't know which window is expecting to show the UI. You should always implement the presentation context provider.

Replies

Glad to hear you're adopting passkeys! If and when the context provider is invoked varies by platform and OS version. It used to get called on iOS only when we felt we needed more context about where to position the sheet. On more recent versions of iOS, iPadOS, and Catalyst, it should get called every time. While we can make good guesses in some scenarios, there are situations where we can't know which window is expecting to show the UI. You should always implement the presentation context provider.