KJTouchIdManager 1.0.2

KJTouchIdManager 1.0.2

Smiacter 维护。



  • Smiacter

描述

在 iOS 8 或更高版本的 iOS 上使用的指纹/面容解锁简单封装

功能            

  • 支持 iOS8+ 兼容iOS8以上系统
  • 支持面容解锁    
  • 支持显示系统密码以确认触控ID  

用法

  1. 将 TouchIdManager 文件夹拖到您的项目目录

  2. 添加通知来处理错误,在当前 VC 处理解锁失败

NotificationCenter.default.addObserver(self, selector: #selector(touchIdErrorHandle(noti:)), name: NSNotification.Name(rawValue: KeyNotificationTouchIdFail), object: nil)
  1. 使用单例激活触控ID
TouchIDManager.shared.useTouchIdUnlock(unlockSuccess: {
            // success handle
            self.dismiss(animated: true, completion: nil)
        }) { (errorType) in
        }
  1. 处理错误
func touchIdErrorHandle(noti: Notification) {
        // type: 1-锁定后验证系统密码成功 0-点击使用密码登录 -1-锁定后验证系统密码失败 -2-验证失败,指纹不匹配
        //       -3-点击取消按钮 -4-被系统取消 -5-被应用取消
        if let userInfo = noti.userInfo, let type = userInfo["type"] as? Int {
            DispatchQueue.main.async {
                switch type {
                case 1:
                    self.touchIdUnlock()
                case 0:
                    break
                case -1:
                    break
                case -2:
                    let alertVC = UIAlertController(title: "提示", message: "指纹不匹配", preferredStyle: .alert)
                    alertVC.addAction(UIAlertAction(title: "确定", style: .default, handler: { (alert) in
                        
                    }))
                    self.present(alertVC, animated: true, completion: nil)
                case -3:
                    break
                case -4:
                    break
                case -5:
                    break
                default:
                    break
                }
            }
        }
    }

MIT