Passkey Authentication

Register or login a user using passkeys on iOS

Register a new user with a passkey

To create a new user account with a passkey, pass the user’s email address or phone number to passage.registerWithPasskey:

do {
    try await passage.registerWithPasskey(identifier: identifier)
    // passage.getCurrentUser should now return the authenticated user
    guard let user = try await passage.getCurrentUser() else { return }
    // Do authenticated stuff
} catch PassageASAuthorizationError.canceled {
    // User cancelled native passkey prompt, do nothing
} catch {
    // Passkey registration failed, try an email or sms registration method instead.
}

Log in an existing user with a passkey

To log in an existing user with a passkey, use passage.loginWithPasskey:

do {
    // This will display a list of any user passkeys associated with your app:
    try await passage.loginWithPasskey()
    // passage.getCurrentUser should now return the authenticated user
    guard let user = try await passage.getCurrentUser() else { return }
    // Do authenticated stuff
} catch PassageASAuthorizationError.canceled {
    // User cancelled native passkey prompt, do nothing
} catch {
    // Passkey login failed, try an email or sms login method instead.
}

Last updated