Is there a way to determine if an item (password, token, etc.) has been set in the iOS keychain using Touch ID access control without prompting the user for Touch ID? We have a need to determine if the credential has already been saved to the keychain (with Touch ID protection) before performing an operation, but we don't want to interrupt the user with the Touch ID prompt.
I've tried the following...
NSMutableDictionary *query = ...
query[(__bridge id)kSecUseNoAuthenticationUI] = (__bridge id)kCFBooleanTrue;
OSStatus opStatus = SecItemCopyMatching((__bridge CFDictionaryRef)query, NULL);
...
However, when this code gets called the user still sees the Touch ID prompt. We don't want ANYTHING to be displayed on the UI, and just want an error returned in the OSStatus
if Touch ID would have been required.
Any thoughts?
kSecUseNoAuthenticationUI : @YES
in @neoneye's answer was changed tokSecUseAuthenticationUI : kSecUseAuthenticationUIFail
: The former has been deprecated in favor of the latter. See: developer.apple.com/documentation/security/… – Omophagia