From 24045a74dd2e8b2422d15d003d36f6e9c9295737 Mon Sep 17 00:00:00 2001 From: Joel Arvidsson Date: Fri, 29 May 2015 18:03:19 +0200 Subject: [PATCH] Dont throw red screen when no matches were found. --- RNKeychainManager/RNKeychainManager.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RNKeychainManager/RNKeychainManager.m b/RNKeychainManager/RNKeychainManager.m index 96fd5aa..e7cd8a5 100644 --- a/RNKeychainManager/RNKeychainManager.m +++ b/RNKeychainManager/RNKeychainManager.m @@ -85,7 +85,7 @@ RCT_EXPORT_METHOD(setInternetCredentialsForServer:(NSString*)server withUsername // Try to save to keychain osStatus = SecItemAdd((__bridge CFDictionaryRef) dict, NULL); - if (osStatus != noErr) { + if (osStatus != noErr && osStatus != errSecItemNotFound) { NSError *error = [NSError errorWithDomain:NSOSStatusErrorDomain code:osStatus userInfo:nil]; return callback(@[makeError(error)]); } @@ -104,7 +104,7 @@ RCT_EXPORT_METHOD(getInternetCredentialsForServer:(NSString*)server callback:(RC CFTypeRef foundTypeRef = NULL; OSStatus osStatus = SecItemCopyMatching((__bridge CFDictionaryRef) dict, (CFTypeRef*)&foundTypeRef); - if (osStatus != noErr) { + if (osStatus != noErr && osStatus != errSecItemNotFound) { NSError *error = [NSError errorWithDomain:NSOSStatusErrorDomain code:osStatus userInfo:nil]; return callback(@[makeError(error)]); } @@ -129,7 +129,7 @@ RCT_EXPORT_METHOD(resetInternetCredentialsForServer:(NSString*)server callback:( // Remove any old values from the keychain OSStatus osStatus = SecItemDelete((__bridge CFDictionaryRef) dict); - if (osStatus != noErr) { + if (osStatus != noErr && osStatus != errSecItemNotFound) { NSError *error = [NSError errorWithDomain:NSOSStatusErrorDomain code:osStatus userInfo:nil]; return callback(@[makeError(error)]); }