Skip to content

Commit 8017024

Browse files
committed
Add ability to sync items w icloud && update README
1 parent bc03232 commit 8017024

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,13 @@ SInfo.setItem('key1', 'value1', {
201201

202202
Note: By default `kSecAccessControl` will get set to `kSecAccessControlUserPresence`.
203203

204+
#### kSecAttrSynchronizable
205+
206+
You can set this to `true` in order to sync the keychain items with iCloud.
207+
208+
Note: By default `kSecAttrSynchronizable` will get set to `false`.
209+
210+
204211
# How to use?
205212

206213
Here is a simple example:

ios/RNSensitiveInfo/RNSensitiveInfo.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ - (NSString *)messageForError:(NSError *)error
124124
valueData, kSecValueData,
125125
key, kSecAttrAccount, nil];
126126

127+
if([RCTConvert BOOL:options[@"kSecAttrSynchronizable"]]){
128+
[query setValue:@YES forKey:(NSString *)kSecAttrSynchronizable];
129+
}
130+
127131
if([RCTConvert BOOL:options[@"touchID"]]){
128132
CFStringRef kSecAccessControlValue = convertkSecAccessControl([RCTConvert NSString:options[@"kSecAccessControl"]]);
129133
SecAccessControlRef sac = SecAccessControlCreateWithFlags(kCFAllocatorDefault, kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly, kSecAccessControlValue, NULL);
@@ -155,6 +159,7 @@ - (NSString *)messageForError:(NSError *)error
155159
NSMutableDictionary* query = [NSMutableDictionary dictionaryWithObjectsAndKeys:(__bridge id)(kSecClassGenericPassword), kSecClass,
156160
keychainService, kSecAttrService,
157161
key, kSecAttrAccount,
162+
kSecAttrSynchronizableAny, kSecAttrSynchronizable
158163
kCFBooleanTrue, kSecReturnAttributes,
159164
kCFBooleanTrue, kSecReturnData,
160165
nil];
@@ -224,6 +229,7 @@ - (void)getItemWithQuery:(NSDictionary *)query resolver:(RCTPromiseResolveBlock)
224229

225230
NSMutableArray* finalResult = [[NSMutableArray alloc] init];
226231
NSMutableDictionary *query = [NSMutableDictionary dictionaryWithObjectsAndKeys:
232+
(__bridge id)kSecAttrSynchronizableAny, kSecAttrSynchronizable,
227233
(__bridge id)kCFBooleanTrue, (__bridge id)kSecReturnAttributes,
228234
(__bridge id)kSecMatchLimitAll, (__bridge id)kSecMatchLimit,
229235
(__bridge id)kCFBooleanTrue, (__bridge id)kSecReturnData,
@@ -285,6 +291,7 @@ - (void)getItemWithQuery:(NSDictionary *)query resolver:(RCTPromiseResolveBlock)
285291
// Create dictionary of search parameters
286292
NSDictionary* query = [NSDictionary dictionaryWithObjectsAndKeys:
287293
(__bridge id)(kSecClassGenericPassword), kSecClass,
294+
(__bridge id)(kSecAttrSynchronizableAny), kSecAttrSynchronizable,
288295
keychainService, kSecAttrService,
289296
key, kSecAttrAccount,
290297
kCFBooleanTrue, kSecReturnAttributes,

0 commit comments

Comments
 (0)