Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 36 additions & 4 deletions ios/RNScreenshotPrevent.m
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,47 @@ -(void) removeSecureTextFieldFromView:(UIView *) view {
}
}


/** removes secure textfield from the view */
RCT_EXPORT_METHOD(disableSecureView) {
[self enabled:NO];
secureField.secureTextEntry = false;
NSLog(@"[RNScreenshotPrevent] disableSecureView called.");

if (secureField != nil) {
NSLog(@"[RNScreenshotPrevent] Found secureField, disabling secure entry.");
secureField.secureTextEntry = NO;

if (secureField.superview) {
NSLog(@"[RNScreenshotPrevent] Removing secureField from its superview.");
[secureField removeFromSuperview];
} else {
NSLog(@"[RNScreenshotPrevent] secureField has no superview.");
}

secureField = nil;
NSLog(@"[RNScreenshotPrevent] secureField reference cleared.");
} else {
NSLog(@"[RNScreenshotPrevent] No secureField found, nothing to disable.");
}

UIView *view = [UIApplication sharedApplication].keyWindow.rootViewController.view;
for(UIView *subview in view.subviews) {
[self removeSecureTextFieldFromView:subview];
if (view == nil) {
NSLog(@"[RNScreenshotPrevent] Root view is nil, cannot remove secure text fields.");
return;
}

NSLog(@"[RNScreenshotPrevent] Checking subviews for secure fields to remove.");
int removedFields = 0;
for (UIView *subview in view.subviews) {
if ([subview isKindOfClass:[UITextField class]]) {
NSLog(@"[RNScreenshotPrevent] Removing a UITextField from subviews.");
[self removeSecureTextFieldFromView:subview];
removedFields++;
}
}

NSLog(@"[RNScreenshotPrevent] Secure view disabled and removed. Total fields removed: %d", removedFields);
}



@end