aiDee (/ɪd/), noun
"... abbreviation for identification: any official card or document with your name and photograph or other information on it that you use to prove who you are."
aiDee is a micro-framework that can be used to authenticate with iOS Devices using biometrics: Touch ID or Face ID. Written in Swift this aims to be a simple example of Apple's not-so-new LocalAuthentication API usage.
As a first step you should add an entry on your Info.plist
file for key NSFaceIDUsageDescription
.
The value should be a string describing the reason why your app uses Touch or Face ID. More information on this subject can be found on Apple's Documentation.
aiDee is available through CocoaPods. Just add the following line to your PodFile:
pod 'aiDee'
And then run the following command on the terminal:
pod install
Add the entry to your Cartfile:
github "aiFigueiredo/aiDee"
And then run the following command on the terminal:
carthage update
import aiDee
...
// Instantiate BiometricAuthentication object
let biometricAuth = BiometricAuthentication()
// Get Biometric Availability Information
let biometricsAvailable: Bool = biometricAuth.isBiometricsAvailable()
let biometricsType: BiometricType = biometricAuth.biometricType() // .touchId / .faceId / .none
// Authenticate using Biometrics providing a LocalizedString with a reason for the request
biometricAuth.authenticateUser(localizedReason: "Reason for Biometric request") { [weak self] result in
if case .success = result {
self?.showAlert(title: "Success", message: "Biometric Auth Successfull")
} else if case .failure(let error) = result {
self?.showAlert(title: "Error", message: error.errorDescription)
}
}
- Both FaceID and TouchID can be tested in the simulator by selecting "Hardware" > "TouchID"/"FaceID" > "Enrolled"
- This micro framework should be used alongside the use of Keychain to store sensitive information.
Feel free to contribute to this project by opening issues or opening pull requests.
aiDee's available under the MIT license. See the LICENSE file for more information.