Search code examples
iosobjective-ciphoneios8touch-id

Touch Id implementation with device's passcode feature


I am implementing touch Id feature In my application. It's working fine for touchID using evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics

I also want to use pass-code option which is alternate for Touch Id, I am referring per apple's demo code for passcode using keychain. Apple Sample Code link

Can't we use it without adding any item using method addItemAsync to ask for passcode? Is there any alternate way to ask device's passcode in our application programmatically?

If I try to use without add, getting error errSecItemNotFound. Please suggest Am I missing anything or we can do with any other way to use device's passcode for our application,


Solution

  • If you want to read an item from the keychain you have to write it first. If the item isn't there then, as you discovered, you will get errSecItemNotFound - because the item wasn't found.

    You simply need to add an item to the keychain when you first run your app - this will then give you an item to authenticate against.