ClinicKit Mobile SDK / iOS

iOS Authentication API

AuthenticateService signs users in to VSee Clinic and manages their session.

Login

userLogin signs a user in with a username and password.

public func userLogin(userName: String,
                      password: String,
                      success: @escaping() -> Void,
                      failure: @escaping (Error) -> Void)
ParameterTypeDescription
userNameStringThe user's username.
passwordStringThe user's password.
successClosureCalled when sign-in succeeds.
failureClosureCalled when sign-in fails, with the error.

Example usage

AuthenticateService.shared.userLogin(userName: username, password: password, success: {
    // Authentication successful
    // Perform any actions or navigate to the next screen
}, failure: { error in
    // Authentication failed
    // Handle the error or display an error message
})

Guest login

guestLogin signs a guest in with a first and last name.

public func guestLogin(_ firstName: String,
                          lastName: String,
                          success: @escaping() -> Void,
                          failure: @escaping (Error) -> Void)
ParameterTypeDescription
firstNameStringThe guest's first name.
lastNameStringThe guest's last name.
successClosureCalled when sign-in succeeds.
failureClosureCalled when sign-in fails, with the error.

Example usage

AuthenticateService.shared.guestLogin(firstName, lastName: lastName, success: {
    // Guest login successful
    // Perform any actions or navigate to the next screen
}, failure: { error in
    // Guest login failed
    // Handle the error or display an error message
})

Login by token (SSO)

loginBySSOToken signs a user in with a single sign-on (SSO) token. See SSO login for the full flow.

public func loginBySSOToken(_ token: String,
                            success: @escaping() -> Void,
                            failure: @escaping (Error) -> Void)
ParameterTypeDescription
tokenStringThe single sign-on token.
successClosureCalled when sign-in succeeds.
failureClosureCalled when sign-in fails, with the error.

Example usage

// Sign in with the provided SSO token
AuthenticateService.shared.loginBySSOToken(ssoToken, success: {
    // Authentication successful
    // Perform any actions or navigate to the next screen
}, failure: { error in
    // Authentication failed
    // Handle the error or display an error message
})

Logout

logoutVC ends the VSee Clinic session.

public func logoutVC(success: @escaping() -> Void,
                    failure: @escaping (Error) -> Void)
ParameterTypeDescription
successClosureCalled when logout succeeds.
failureClosureCalled when logout fails, with the error.

Example usage

AuthenticateService.shared.logoutVC(success: {
    // Logout successful
    // Perform actions after successful logout
}) { error in
    // Logout failed
    // Handle the error or display an error message
}

Restore a signed-in session

restoreLoginSession restores the previous user's session.

public func restoreLoginSession(success: @escaping() -> Void,
                                failure: @escaping (Error) -> Void)
ParameterTypeDescription
successClosureCalled when the session is restored.
failureClosureCalled when the session can't be restored, with the error.

Example usage

// Restore the session of the previously signed-in user
AuthenticateService.shared.restoreLoginSession(success: {
    // Session restored
    // Perform any necessary actions or navigate to the next screen
}, failure: { error in
    // Failed to restore the session
    // Handle the error or display an error message
})