-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathKeychainBridge.m
More file actions
34 lines (28 loc) · 831 Bytes
/
KeychainBridge.m
File metadata and controls
34 lines (28 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//
// KeychainBridge.m
// AnyGif
//
// Created by Dave on 4/19/15.
//
#import "KeychainBridge.h"
#import "FXKeychain.h"
#import "RCTLog.h"
@implementation KeychainBridge
RCT_EXPORT_MODULE();
RCT_EXPORT_METHOD(setObjectsAndKeys:(NSDictionary *)objects) {
[objects enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
[[FXKeychain defaultKeychain] setObject:obj forKey:key];
RCTLog([NSString stringWithFormat:@"set %@: %@", obj, key]);
}];
}
RCT_EXPORT_METHOD(getObjectForKey:(id)key callback:(RCTResponseSenderBlock)callback) {
id result = [[FXKeychain defaultKeychain] objectForKey:key];
if (result) {
callback(@[[NSNull null], result]);
RCTLog([NSString stringWithFormat:@"get %@: %@", key, result]);
} else {
callback(@[@"missing key"]);
RCTLog(@"Missing key");
}
}
@end