Skip to content

Commit

Permalink
Return error if isProtectedDataAvailable = false
Browse files Browse the repository at this point in the history
Addresses issue mCodex#72 where SecItemCOpyMatching doesn't return data and
doesn't give an error when the protected files are not yet
available. This will now give an error instead of empty results,
allowing the caller to retry after some delay.
  • Loading branch information
Kelly Campbell authored and Kelly Campbell committed Feb 19, 2020
1 parent 4c96437 commit e05d8f3
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ios/RNSensitiveInfo/RNSensitiveInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,15 @@ - (NSString *)messageForError:(NSError *)error
return;
}

[self getItemWithQuery:query resolver:resolve rejecter:reject];
dispatch_async(dispatch_get_main_queue(), ^{
if (UIApplication.sharedApplication.protectedDataAvailable) {
[self getItemWithQuery:query resolver:resolve rejecter:reject];
} else {
// TODO: could change to instead of erroring out, listen for protectedDataDidBecomeAvailable and call getItemWIthQuery when it does
// Experiment for now by returning an error and let the js side retry
reject(@"protected_data_unavailable", @"Protected data not available yet. Retry operation", nil);
}
});
}

- (void)getItemWithQuery:(NSDictionary *)query resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject {
Expand Down

0 comments on commit e05d8f3

Please sign in to comment.