Face Id Authentication integration into the app
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
MTFaceIdAuthentication.xcodeproj
MTFaceIdAuthentication
FaceIDAuthenticating.PNG
FaceIDAuthenticationFail.PNG
FaceIDAuthenticationSuccess.PNG
README.md

README.md

FaceId-Authentication-IphoneX

Face Id Authentication integration into the app

The code demonstrates how to integrate Face Id authentication integration into the app. Face Id is currently supported on iPhone X. This Code also works for touchId authentication.

Detailed explanation of the code is available at https://machinethinks.com/faceid-authentication-in-ios11-swift/.

Class MTBiometricAuthentication in this project is responsible for biometeric authentication and notify the success / fail status with Post Notification

How to use MTBiometricAuthentication class.

  1. Create an instance of MTBiometricAuthentication class
  2. Call authenticationWithBiometricID to initiate the authentication process
  3. Add notification observerers as below:

NotificationCenter.default.addObserver(self, selector: #selector(LoginVC.authenticationCompletionHandler(loginStatusNotification:)), name: .MTBiometricAuthenticationNotificationLoginStatus, object: nil)

  1. Typecast userInfo[MTBiometricAuthentication.status] to MTBiomericAuthenticationStatus instance (authStatus) that holds the response object. a) check if authStatus.success is true for successfull authentication b) if authStatus.success is false, check for authStatus.errorMessage for error message and authStatus.errorCode for LAError code. Currently all the possible error codes are mapped to error message in the response.

Output Screenshot from this project:

alt text