TJBioAuthentication
适用于 touchID 和 faceID 的 Apple 生物识别认证
特性
- FaceID 验证
- TouchID 验证
- 密码验证
- 电池错误处理
要求
- iOS 10.0+
- Xcode 9.0
安装
CocoaPods
CocoaPods 是一个用于 Cocoa 项目的依赖管理器。你可以使用以下命令安装它
$ gem install cocoapods
要使用 CocoaPods 将 TJBioAuthentication 集成到你的 Xcode 项目中,请在你的 Podfile
中指定它
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
target '<Your Target Name>' do
pod 'TJBioAuthentication'
end
然后,运行以下命令
$ pod install
手动
- 下载并将
TJAuthErrors.swift
、TJBioAuthenticator.swift
和TJDefaultMessages.swift
文件拖放到您的项目中。 - 恭喜!
用法
注意: - 要使用面容ID,您需要在您的info.plist文件中添加以下行
<key>NSFaceIDUsageDescription</key>
<string>$(PRODUCT_NAME) requires Face ID permission to authenticate using Face recognition.</string>
检查生物识别是否可用。
if TJBioAuthenticator.shared.isBiometricAuthenticationAvailable(){
// Bio metric is available, write your code here
}
检查面容ID是否可用。
if TJBioAuthenticator.shared.isFaceIDAvailable(){
// FaceID is available, write your code here
}
使用生物识别进行认证。
TJBioAuthenticator.shared.authenticateUserWithBioMetrics(success: {
// Biometric Authentication success
}) { (error) in
// Biometric Authentication unsuccessful
}
使用密码进行认证。
TJBioAuthenticator.shared.authenticateUserWithPasscode(success: {
// Biometric Authentication success
}) { (error) in
// Biometric Authentication unsuccessful
}
贡献
我们非常感谢您对 TJBioAuthentication 的贡献,有关更多信息,请检查 LICENSE
文件。
作者
Tejas Ardeshna – @tejas_ardeshna – [email protected]
在MIT许可证下分发。有关更多信息,请参阅LICENSE
。