WWTouchIdTesting 0.3.0

WWTouchIdTesting 0.3.0

Maintained by William-Weng.



  • By
  • 翁禹斌(William.Weng)

WWTouchIdTesting

使用TouchID / FaceID的功能封裝

Swift 4.2 Version Platform License

使用TouchID / FaceID的功能封裝 (上傳至Cocoapods)

使用範例

IBOutlet

import UIKit
import WWTouchIdTesting

class ViewController: UIViewController {

    @IBOutlet weak var successLabel: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    /// TouchID / FaceID 測試 (info.plist => NSFaceIDUsageDescription)
    @IBAction func touchIdAction(_ sender: UIButton) {
        
        let myBiometryType = WWTouchIdTesting.run(reason: "ID辨識測試") { policyResult in
            
            DispatchQueue.main.async {
                switch policyResult {
                case .failure(let error):
                    self.successLabel.backgroundColor = .red
                    print("error = \(error.debugDescription)")
                case .success(let isOK):
                    self.successLabel.backgroundColor = .green
                    print("isOK = \(isOK.debugDescription)")
                }
            }
        }
        
        successLabel.text = "\(myBiometryType.toString())"
    }
}