Skip to content

Commit 0a06416

Browse files
fix key value not upated
1 parent ea981d0 commit 0a06416

File tree

3 files changed

+48
-16
lines changed

3 files changed

+48
-16
lines changed

example/ios/example.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,10 @@
591591
CreatedOnToolsVersion = 6.2;
592592
TestTargetID = 13B07F861A680F5B00A75B9A;
593593
};
594+
13B07F861A680F5B00A75B9A = {
595+
DevelopmentTeam = YMTR567S22;
596+
ProvisioningStyle = Automatic;
597+
};
594598
2D02E47A1E0B4A5D006451C7 = {
595599
CreatedOnToolsVersion = 8.2.1;
596600
ProvisioningStyle = Automatic;
@@ -1043,8 +1047,10 @@
10431047
isa = XCBuildConfiguration;
10441048
buildSettings = {
10451049
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
1050+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
10461051
CURRENT_PROJECT_VERSION = 1;
10471052
DEAD_CODE_STRIPPING = NO;
1053+
DEVELOPMENT_TEAM = YMTR567S22;
10481054
HEADER_SEARCH_PATHS = (
10491055
"$(inherited)",
10501056
"$(SRCROOT)/../node_modules/react-native-secure-key-store/ios/**",
@@ -1056,7 +1062,9 @@
10561062
"-ObjC",
10571063
"-lc++",
10581064
);
1065+
PRODUCT_BUNDLE_IDENTIFIER = com.reactlibrarys.securekeystore;
10591066
PRODUCT_NAME = example;
1067+
PROVISIONING_PROFILE_SPECIFIER = "";
10601068
VERSIONING_SYSTEM = "apple-generic";
10611069
};
10621070
name = Debug;
@@ -1065,7 +1073,9 @@
10651073
isa = XCBuildConfiguration;
10661074
buildSettings = {
10671075
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
1076+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
10681077
CURRENT_PROJECT_VERSION = 1;
1078+
DEVELOPMENT_TEAM = YMTR567S22;
10691079
HEADER_SEARCH_PATHS = (
10701080
"$(inherited)",
10711081
"$(SRCROOT)/../node_modules/react-native-secure-key-store/ios/**",
@@ -1077,7 +1087,9 @@
10771087
"-ObjC",
10781088
"-lc++",
10791089
);
1090+
PRODUCT_BUNDLE_IDENTIFIER = com.reactlibrarys.securekeystore;
10801091
PRODUCT_NAME = example;
1092+
PROVISIONING_PROFILE_SPECIFIER = "";
10811093
VERSIONING_SYSTEM = "apple-generic";
10821094
};
10831095
name = Release;

example/ios/example/Info.plist

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<key>CFBundleExecutable</key>
1010
<string>$(EXECUTABLE_NAME)</string>
1111
<key>CFBundleIdentifier</key>
12-
<string>org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)</string>
12+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
1313
<key>CFBundleInfoDictionaryVersion</key>
1414
<string>6.0</string>
1515
<key>CFBundleName</key>
@@ -24,6 +24,19 @@
2424
<string>1</string>
2525
<key>LSRequiresIPhoneOS</key>
2626
<true/>
27+
<key>NSAppTransportSecurity</key>
28+
<dict>
29+
<key>NSExceptionDomains</key>
30+
<dict>
31+
<key>localhost</key>
32+
<dict>
33+
<key>NSExceptionAllowsInsecureHTTPLoads</key>
34+
<true/>
35+
</dict>
36+
</dict>
37+
</dict>
38+
<key>NSLocationWhenInUseUsageDescription</key>
39+
<string></string>
2740
<key>UILaunchStoryboardName</key>
2841
<string>LaunchScreen</string>
2942
<key>UIRequiredDeviceCapabilities</key>
@@ -38,19 +51,5 @@
3851
</array>
3952
<key>UIViewControllerBasedStatusBarAppearance</key>
4053
<false/>
41-
<key>NSLocationWhenInUseUsageDescription</key>
42-
<string></string>
43-
<key>NSAppTransportSecurity</key>
44-
<!--See http://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/ -->
45-
<dict>
46-
<key>NSExceptionDomains</key>
47-
<dict>
48-
<key>localhost</key>
49-
<dict>
50-
<key>NSExceptionAllowsInsecureHTTPLoads</key>
51-
<true/>
52-
</dict>
53-
</dict>
54-
</dict>
5554
</dict>
5655
</plist>

ios/RNSecureKeyStore.m

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,22 @@ - (BOOL)createKeychainValue:(NSString *)value forIdentifier:(NSString *)identifi
6666
return NO;
6767
}
6868

69+
- (BOOL)updateKeychainValue:(NSString *)password forIdentifier:(NSString *)identifier {
70+
71+
NSMutableDictionary *searchDictionary = [self newSearchDictionary:identifier];
72+
NSMutableDictionary *updateDictionary = [[NSMutableDictionary alloc] init];
73+
NSData *passwordData = [password dataUsingEncoding:NSUTF8StringEncoding];
74+
[updateDictionary setObject:passwordData forKey:(id)kSecValueData];
75+
76+
OSStatus status = SecItemUpdate((CFDictionaryRef)searchDictionary,
77+
(CFDictionaryRef)updateDictionary);
78+
79+
if (status == errSecSuccess) {
80+
return YES;
81+
}
82+
return NO;
83+
}
84+
6985
- (void)deleteKeychainValue:(NSString *)identifier {
7086
NSMutableDictionary *searchDictionary = [self newSearchDictionary:identifier];
7187
SecItemDelete((CFDictionaryRef)searchDictionary);
@@ -86,7 +102,12 @@ - (void)deleteKeychainValue:(NSString *)identifier {
86102
if (status) {
87103
resolve(@"key stored successfully");
88104
} else {
89-
reject(@"no_events", @"Not able to save key", secureKeyStoreError(@"Not able to save key"));
105+
BOOL status = [self updateKeychainValue: value forIdentifier: key];
106+
if (status) {
107+
resolve(@"key updated successfully");
108+
} else {
109+
reject(@"no_events", @"Not able to save key", secureKeyStoreError(@"Not able to save key"));
110+
}
90111
}
91112
}
92113
@catch (NSException *exception) {

0 commit comments

Comments
 (0)