Skip to content

Commit e05d8f3

Browse files
Kelly CampbellKelly Campbell
authored andcommitted
Return error if isProtectedDataAvailable = false
Addresses issue #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.
1 parent 4c96437 commit e05d8f3

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

ios/RNSensitiveInfo/RNSensitiveInfo.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,15 @@ - (NSString *)messageForError:(NSError *)error
215215
return;
216216
}
217217

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

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

0 commit comments

Comments
 (0)