Building the UI There are several ways that you can build UI flows in iOS applications. You can use Model-View-ViewModel (MVVM), Viper, or massive view controllers. How you manage transitions between view controllers is up to you, however we recommend the use of the flow coordinator pattern . Your flow coordinator instance handles all of the status updates and manages UI navigation. We've also implemented this pattern in our sample application .
For example, your application could have the following view controllers:
LoginViewController
- responsible for reading the username and password information from a user and initiating the authentication flow via OktaAuthSdk
PasswordChangeViewController
- responsible for the change password or skip actions MFARequiredViewController
- responsible for showing the user their enrolled active factors MFAChallengeViewController
- responsible for factor verification and retry actions The flow coordinator decides which view controller to show next based on the current status that is received from the server. For example, if the current status is OktaAuthStatusPasswordChange
, then the flow coordinator shows PasswordChangeViewController
and injects the current status as a dependency.
Primary authentication flow With the primary authentication flow (no MFA, no password management, and so on), you typically just need LoginViewController
. LoginViewController
is your root view controller that expects the username and password to be input by the user. Let's assume that your view controller has the following UI outlets: userNameTextField
, passwordTextField
, and signInButton
. Then, the handler for the tap on signInButton
could be:
If the user is authenticated, then the SDK returns the OktaAuthStatusSuccess
status in the onStatusChange
closure parameter.
The following is an example of an AuthFlowCoordinator
implementation. Let's assume that your LoginViewController
has the flowCoordinatorDelegate
property. The property is declared with the AuthFlowCoordinatorProtocol
type and required for delegating status handling responsilbity to the AuthFlowCoordinator
object.
AuthFlowCoordinatorProtocol
AuthFlowCoordinator