Skip to content

Commit d41e4ae

Browse files
committed
getItem now returns null if item never was set before, README.md cleanup
1 parent 863d3e9 commit d41e4ae

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ We unified our library's methods to bring more efficiency and simplify the usabi
143143

144144
```javascript
145145
SInfo.setItem('key1', 'value1', {
146-
sharedPreferencesName: 'mySharedPrefs',
147-
keychainService: 'myKeychain',
148-
encrypt: true});
146+
sharedPreferencesName: 'mySharedPrefs',
147+
keychainService: 'myKeychain'
148+
});
149149
```
150150

151151
If you used Android's getDefaultSharedPreferences in your project the shared preference's name that you are looking for is: **com.mypackage.MyApp_preferences**. On the other hand if you used iOS's Keychain the default service is: **app** which is our default too.
@@ -180,7 +180,7 @@ SInfo.setItem('key1', 'value1', {
180180
keychainService: 'myKeychain',
181181
kSecAccessControl: 'kSecAccessControlTouchIDCurrentSet',
182182
sharedPreferencesName: 'mySharedPrefs',
183-
touchID: true,
183+
touchID: true
184184
});
185185
```
186186

android/src/main/java/br/com/classapp/RNSensitiveInfo/RNSensitiveInfoModule.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,14 @@ public void getItem(String key, ReadableMap options, Promise pm) {
161161
HashMap strings = options.hasKey("strings") ? options.getMap("strings").toHashMap() : new HashMap();
162162

163163
decryptWithAes(value, showModal, strings, pm, null);
164-
} else {
164+
} else if (value != null) {
165165
try {
166166
pm.resolve(decrypt(value));
167167
} catch (Exception e) {
168168
pm.reject(e);
169169
}
170+
} else {
171+
pm.resolve(value);
170172
}
171173
}
172174

@@ -252,7 +254,7 @@ private void putExtra(String key, String value, SharedPreferences mSharedPrefere
252254
}
253255

254256
/**
255-
* Generates a new AES key and stores it under the { @code KEY_ALIAS } in the
257+
* Generates a new RSA key and stores it under the { @code KEY_ALIAS } in the
256258
* Android Keystore.
257259
*/
258260
private void initKeyStore() {

0 commit comments

Comments
 (0)