NKTouchID is easy drop in solution for using Touch ID in your iPhone application using swift
Based on Werbary/WBTouchID
- Copy NKTouchID.swift to your project
- Add LocalAuthentication.framework as optional dependency
- Add touchID.reason key to Localizable.string table if you want (it is the text that will appear on Touch ID alert)
- Call:
NKTouchID.authenticateWithTouchId(callback: { (success, error) in
if success {
println("Autheticated successfully");
} else {
println("Failed to authenticate: \(error!.localizedDescription)");
}
})
Or if you want a better handling of the reason param
NKTouchID.authenticateWithTouchId(reason: "Custom reason", callback: { (success, error) in
if success {
println("Autheticated successfully");
} else {
println("Failed to authenticate: \(error!.localizedDescription)");
}
})