4

我在一些 touchId 应用程序中看到SecItemUpdate了 touchId UI 屏幕从不弹出并且更新仍然发生。我的应用程序需要类似的功能,并且根据我从 Apple Developer's guide 中阅读的内容(我的理解可能是错误的)提出了一些选项,但它们似乎不起作用。这是我到目前为止所做的。

设置kSecUseNoAuthenticationUIYES,返回错误代码-25308。设置kSecUseNoAuthenticationUINO,返回错误代码-50。如果我不包含kSecUseNoAuthenticationUI,则会弹出默认身份验证 UI。

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];
});]

所以我在这一点上迷路了。感谢您能否给我一些关于如何在 SecItemUpdate 上禁用此 touchId UI 弹出窗口的指示。谢谢

4

2 回答 2

4

如果您观看视频 WWDC 2014 Session 711,kSecUseNoAuthenticationUI会在 31:35 左右提到。

您也可以查看 "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.

我不确定您是否可以禁用弹出窗口并执行更新。

我想了解的是:设置kSecUseNoAuthenticationUI选项不会显示弹出窗口。但是,如果您尝试访问需要身份验证的项目,它将通过返回 aerrSecInteractionNotAllowed作为操作结果来指示您该项目失败

于 2015-03-10T08:21:29.073 回答
1

根据 iOS8 发行说明,这应该是这种情况,您应该删除并重新添加您的项目

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

      if (status == errSecSuccess) {
        status = SecItemAdd((__bridge CFDictionaryRef)attributes, nil);
      }
}
于 2015-12-11T15:55:05.970 回答