Browse Source

check without UI

Marco Cancellieri 7 years ago
parent
commit
5c0e08ebc5
1 changed files with 6 additions and 1 deletions
  1. 6 1
      Lib/KeychainAccess/Keychain.swift

+ 6 - 1
Lib/KeychainAccess/Keychain.swift

@@ -744,11 +744,16 @@ public final class Keychain {
     public func contains(_ key: String) throws -> Bool {
     public func contains(_ key: String) throws -> Bool {
         var query = options.query()
         var query = options.query()
         query[AttributeAccount] = key
         query[AttributeAccount] = key
-
+        if #available(iOSApplicationExtension 9.0, *) {
+            query[UseAuthenticationUI] = UseAuthenticationUIFail
+        }
+        
         let status = SecItemCopyMatching(query as CFDictionary, nil)
         let status = SecItemCopyMatching(query as CFDictionary, nil)
         switch status {
         switch status {
         case errSecSuccess:
         case errSecSuccess:
             return true
             return true
+        case errSecInteractionNotAllowed:
+            return true
         case errSecItemNotFound:
         case errSecItemNotFound:
             return false
             return false
         default:
         default: