How to link Touch ID with login credentials? How to link Touch ID with login credentials? xcode xcode

How to link Touch ID with login credentials?


You want to store the login information in the keychain, but you need to make sure that the accessibility parameter is set to kSecAttrAccessibleWhenUnlocked or kSecAttrAccessibleWhenUnlockedThisDeviceOnly (kSecAttrAccessibleWhenUnlockedThisDeviceOnly is a bit safer since the password will not leave the device, say when the device is backed up to your laptop.)

NSMutableDictionary *query = [NSMutableDictionary dictionary];[query setObject:(id)kSecClassGenericPassword forKey:(id)kSecClass];[query setObject:account forKey:(id)kSecAttrAccount];[query setObject:(id)kSecAttrAccessibleWhenUnlocked forKey:(id)kSecAttrAccessible];[query setObject:[inputString dataUsingEncoding:NSUTF8StringEncoding] forKey:(id)kSecValueData];OSStatus error = SecItemAdd((CFDictionaryRef)query, NULL);

(Code is from http://software-security.sans.org/blog/2011/01/05/using-keychain-to-store-passwords-ios-iphone-ipad/