user1657861
user1657861

Reputation: 281

Hiding the TouchId popup on SecItemUpdate

I have seen in some touchId apps where on SecItemUpdate the touchId UI screen never pops up and the update still happens. I need similar functionality for my app and based on what I have read from Apple Developer's guide (my understanding maybe wrong) have come up with some options but they don't seem to work. Here's what I have done so far.

Setting kSecUseNoAuthenticationUI to YES, an error code -25308 is returned. Setting kSecUseNoAuthenticationUI to NO, an error code -50 is returned. If I don't include kSecUseNoAuthenticationUI, then the default authentication UI pops up.

NSDictionary *query = @{(__bridge id)kSecClass: (__bridge id)kSecClassGenericPassword,
                        (__bridge id)kSecAttrService: @"SampleService",
                        (__bridge id)kSecUseNoAuthenticationUI: @YES
                        };

NSDictionary *changes = @{
    (__bridge id)kSecValueData: [@"UPDATED_SECRET_PASSWORD_TEXT" dataUsingEncoding:NSUTF8StringEncoding]
    };

dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    OSStatus status = SecItemUpdate((__bridge CFDictionaryRef)query, (__bridge CFDictionaryRef)changes);
    NSString *msg = [NSString stringWithFormat:NSLocalizedString(@"SEC_ITEM_UPDATE_STATUS", nil), [self keychainErrorToString:status]];
    [super printResult:self.textView message:msg];
});]

So I am lost at this point. Appreciate if you can give me some pointers on how to disable this touchId UI popup on SecItemUpdate. Thanks

Upvotes: 4

Views: 1276

Answers (2)

Daniel Broad
Daniel Broad

Reputation: 2522

According to the iOS8 release notes, this supposed is the case and you should delete and re-add your item

if (status == errSecDuplicateItem) { // exists
      status = SecItemDelete((__bridge CFDictionaryRef)attributes);

      if (status == errSecSuccess) {
        status = SecItemAdd((__bridge CFDictionaryRef)attributes, nil);
      }
}

Upvotes: 1

yageek
yageek

Reputation: 4455

If you take a look at video WWDC 2014 Session 711, the kSecUseNoAuthenticationUI is mentioned around 31:35.

You can look also in "SecItem.h" :

 @constant kSecUseNoAuthenticationUI Specifies a dictionary key whose value
        is a CFBooleanRef. If provided with a value of kCFBooleanTrue, the error
        errSecInteractionNotAllowed will be returned if the item is attempting
        to authenticate with UI.

I'm not sure you can both disable the pop-up and perform an update.

What I suppose to understand : setting the kSecUseNoAuthenticationUI option will not display the pop-up. But if you 're trying to access to an item that requires an authentication, it will fail by indicating you that the item by returning a errSecInteractionNotAllowed as the operation result

Upvotes: 4

Related Questions