Skip to main content
This guide provides an overview of how to get started integrating the WebAuthn passkey factor in iOS apps, for secure web-based authentication. On iOS, ASWebAuthenticationSession enables SwiftUI apps to authenticate users via a web service, presenting a secure and user-friendly popup browser for login flows.

Setup

  1. Import the required frameworks:
  • AuthenticationServices
  • SwiftUI
  1. Define your backend authentication URL and a custom URL scheme for callback handling.

Full code example

Notes

  • Replace const_baseUrl with your backend authentication URL.
  • The session uses prefersEphemeralWebBrowserSession = true to avoid sharing cookies or data with Safari and popups.

Troubleshooting

  • Ensure the callback URL scheme matches your app’s registered scheme.