You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
3.9 KiB
98 lines
3.9 KiB
//
|
|
// BiometricAuthenticationWireframe.swift
|
|
// GME Remit
|
|
//
|
|
// Created by InKwon Kim on 30/03/2019.
|
|
//Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
import LocalAuthentication
|
|
|
|
class BiometricAuthenticationWireframe {
|
|
weak var view: UIViewController!
|
|
var completion: ((String?) -> ())?
|
|
var information: String?
|
|
}
|
|
|
|
extension BiometricAuthenticationWireframe: BiometricAuthenticationWireframeInput {
|
|
var storyboardName: String {return "BiometricAuthentication"}
|
|
|
|
func getMainView() -> UIViewController {
|
|
let service = BiometricAuthenticationService()
|
|
let interactor = BiometricAuthenticationInteractor(service: service)
|
|
let presenter = BiometricAuthenticationPresenter()
|
|
let viewController = viewControllerFromStoryboard(of: BiometricAuthenticationViewController.self)
|
|
|
|
viewController.presenter = presenter
|
|
interactor.output = presenter
|
|
presenter.interactor = interactor
|
|
presenter.wireframe = self
|
|
presenter.information = information
|
|
presenter.view = viewController
|
|
|
|
self.view = viewController
|
|
return viewController
|
|
}
|
|
|
|
func showAuthentication() {
|
|
let context = LAContext()
|
|
|
|
var error: NSError?
|
|
let msg = "Confirm your fingerprint or face to authenticate."
|
|
let deviceAuth = LAPolicy.deviceOwnerAuthentication
|
|
|
|
if context.canEvaluatePolicy(deviceAuth, error: &error) {
|
|
context.evaluatePolicy(deviceAuth, localizedReason: msg, reply: { (success, err) in
|
|
if success {
|
|
DispatchQueue.main.async {
|
|
self.completion?(nil)
|
|
}
|
|
} else {
|
|
|
|
let message: String
|
|
|
|
if #available(iOS 11.0, *) {
|
|
switch err {
|
|
case LAError.authenticationFailed?:
|
|
message = "There was a problem verifying your identity."
|
|
case LAError.userCancel?:
|
|
message = "You pressed cancel."
|
|
case LAError.userFallback?:
|
|
message = "You pressed password."
|
|
case LAError.biometryNotAvailable?:
|
|
message = "Face ID/Touch ID is not available."
|
|
case LAError.biometryNotEnrolled?:
|
|
message = "Face ID/Touch ID is not set up."
|
|
case LAError.biometryLockout?:
|
|
message = "Face ID/Touch ID is locked."
|
|
default:
|
|
message = "Face ID/Touch ID may not be configured"
|
|
}
|
|
} else {
|
|
switch err {
|
|
case LAError.authenticationFailed?:
|
|
message = "There was a problem verifying your identity."
|
|
case LAError.userCancel?:
|
|
message = "You pressed cancel."
|
|
case LAError.userFallback?:
|
|
message = "You pressed password."
|
|
case LAError.touchIDNotAvailable?:
|
|
message = "Face ID/Touch ID is not available."
|
|
case LAError.touchIDNotEnrolled?:
|
|
message = "Face ID/Touch ID is not set up."
|
|
case LAError.touchIDLockout?:
|
|
message = "Face ID/Touch ID is locked."
|
|
default:
|
|
message = "Face ID/Touch ID may not be configured"
|
|
}
|
|
|
|
}
|
|
self.completion?(message)
|
|
}
|
|
})
|
|
} else {
|
|
completion?(error?.localizedDescription)
|
|
}
|
|
}
|
|
}
|