PasscodeLockManager

public class PasscodeLockManager

Utility class that manages the passcode/PIN lock screen.

Call initialize() in the AppDelegate.

  • Initializes the global passcode/PIN manager, which uses the iOS KeyChain as PIN code repository.

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { PasscodeLockManager.initialize() }

    Declaration

    Swift

    public static func initialize(logoImage: UIImage?)
  • Clean up any hooks that were made in initialize().

    func applicationWillTerminate(_ application: UIApplication) {
        PasscodeLockManager.cleanup()
    }
    

    Declaration

    Swift

    public static func cleanup()
  • Utility method to check whether Touch-ID is available and enabled.

    Declaration

    Swift

    public static func hasEnrolledFingerprints() -> Bool

    Return Value

    true iff Touch-ID is available and enabled.

  • Create a PasscodeLock view controller, requesting the user to set at new passcode. The passcode information will be stored in iOS keychain.

    @IBAction func nextButton_Click(_ sender: Any) { PasscodeLockManager.showSetPasscode(parentVC: self, successCallback: { _ in }) }

    Declaration

    Swift

    public static func createSetPasscodeImmediateVC(successCallback: ((String) -> ())?) -> UIViewController
  • Create a PasscodeLock view controller, requesting the user to set a new passcode. The passcode information will be stored in iOS keychain.

    @IBAction func nextButton_Click(_ sender: Any) { PasscodeLockManager.showSetPasscode(parentVC: self, successCallback: { _ in }) }

    Declaration

    Swift

    public static func createSetPasscodeVC(successCallback: (() -> ())?) -> UIViewController
  • Create a PasscodeLock view controller, requesting the user to enter a passcode. The passcode entered is then passed back in the success callback.

    @IBAction func loginButton_Click(_ sender: Any) { PasscodeLockManager.createEnterPasscodeImmediateVC(successCallback: { _ in }) }

    Declaration

    Swift

    public static func createEnterPasscodeNoTouchImmediateVC(successCallback: ((String) -> ())?) -> UIViewController
  • Create a PasscodeLock view controller, requesting the user to enter a passcode. The passcode is compared with the one stored in iOS Keychain.

    @IBAction func loginButton_Click(_ sender: Any) { PasscodeLockManager.createEnterPasscode(successCallback: { _ in }) }

    Declaration

    Swift

    public static func createEnterPasscodeNoTouch(successCallback: ((String) -> ())?) -> UIViewController
  • Show the PasscodeLock view controller, requesting the user to change the current PIN.

        @IBAction func nextButton_Click(_ sender: Any) {
            PasscodeLockManager.showSetPasscode(parentVC: self, successCallback: { _ in })
        }
    

    Declaration

    Swift

    public static func showSetPasscode(parentVC: UIViewController, successCallback: (() -> ())?)
  • Show the PasscodeLock view controller, requesting the user to change the current PIN.

    @IBAction func changePinCodeButton_Click(_ sender: Any) {
        PasscodeLockManager.showChangePasscode(parentVC: self, successCallback: { _ in })
    }
    

    Declaration

    Swift

    public static func showChangePasscode(parentVC: UIViewController, successCallback: (() -> ())?)
  • Show the PasscodeLock view controller and invoke the callback when the correct PIN code was entered.

    @IBAction func loginButton_Click(_ sender: Any) {
        PasscodeLockManager.showEnterPasscode(parentVC: self, successCallback: { _ in })
    }
    

    Declaration

    Swift

    public static func showEnterPasscode(parentVC: UIViewController, successCallback: (() -> ())?)
  • Same as showEnterPasscode but does not actually require a correct PIN to continue. This can be used to swap out the root view before the app loses focus.

    func applicationDidEnterBackground(_ application: UIApplication) {
        PasscodeLockManager.showEnterPasscodeFake()
    }
    

    Declaration

    Swift

    public static func showEnterPasscodeFake()
  • Like showEnterPasscode, but replaces the root view controller with a new PasscodeLock view controller.

    Declaration

    Swift

    public static func showEnterPasscodeRoot(successCallback: @escaping (() -> ()))
  • Set the currently stored passcode/PIN.

    Declaration

    Swift

    public static func setPasscode(passcode: String)
  • Check whether the user has configured a passcode.

    Declaration

    Swift

    public static func hasPasscode() -> Bool

    Return Value

    true iff a passcode has been configured.

  • Erase the currently stored passcode/PIN.

    private func restartRegistration() { PasscodeLockManager.clearPasscode() }

    Declaration

    Swift

    public static func clearPasscode()
  • Set/get whether the user can use Touch-ID with any enrolled fingerprint to unlock.

    Declaration

    Swift

    public static var AllowFingerPrintUnlock : Bool