Skip to content

Commit

Permalink
Merge pull request #26 from bbonanno/master
Browse files Browse the repository at this point in the history
setItem() returns the set value in the promise
  • Loading branch information
mCodex authored May 25, 2017
2 parents 589bd5d + ec14128 commit d795d3e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void setItem(String key, String value, ReadableMap options, Promise pm) {

try {
putExtra(key, value, prefs(name));
pm.resolve(null);
pm.resolve(value);
} catch (Exception e) {
Log.d("RNSensitiveInfo", e.getCause().getMessage());
pm.reject(e);
Expand Down
4 changes: 3 additions & 1 deletion ios/RNSensitiveInfo/RNSensitiveInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ @implementation RNSensitiveInfo
}


RCT_EXPORT_METHOD(setItem:(NSString*)key value:(NSString*)value options:(NSDictionary *)options){
RCT_EXPORT_METHOD(setItem:(NSString*)key value:(NSString*)value options:(NSDictionary *)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject){

NSString * keychainService = [RCTConvert NSString:options[@"keychainService"]];
if (keychainService == NULL) {
Expand All @@ -81,6 +81,8 @@ @implementation RNSensitiveInfo

OSStatus osStatus = SecItemDelete((__bridge CFDictionaryRef) query);
osStatus = SecItemAdd((__bridge CFDictionaryRef) query, NULL);

resolve(value);
}

RCT_EXPORT_METHOD(getItem:(NSString *)key options:(NSDictionary *)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject){
Expand Down

0 comments on commit d795d3e

Please sign in to comment.