Skip to content

Commit

Permalink
chore: keyWindow is deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
wn-na committed Nov 4, 2024
1 parent 2def1c1 commit 2d742a5
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions ios/CaptureProtection.mm
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,13 @@ - (void)createRecordProtectionScreen {
UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
UIViewController *captureProtectScreenController = (UIViewController *)[[window viewWithTag:TAG_RECORD_PROTECTION_SCREEN] nextResponder];
if (captureProtectScreenController == nil) {
if(self->protecterViewController == nil) {
[self createRecordProtectionScreenWithText:@"record Detected"];
if(self->protecterViewController != nil) {
[self->protecterViewController willMoveToParentViewController:nil];
[self->protecterViewController.view removeFromSuperview];
[self->protecterViewController removeFromParentViewController];
}
[self createRecordProtectionScreenWithText:@"record Detected"];


[window.rootViewController addChildViewController:self->protecterViewController];
[window.rootViewController.view addSubview:self->protecterViewController.view];
Expand Down Expand Up @@ -207,7 +211,7 @@ - (void)secureBackgroundView: (BOOL)show {
viewController.view.window.windowLevel = UIWindowLevelAlert;
self->protecterScreenViewController = viewController;
viewController.view.backgroundColor = UIColor.whiteColor;
UIWindow *window = [UIApplication sharedApplication].keyWindow;
UIWindow *window = [[UIApplication sharedApplication] delegate].window;

[window makeKeyAndVisible];

Expand All @@ -232,12 +236,13 @@ - (void)secureScreenshotView: (BOOL)isSecure {
self->secureTextField = [[UITextField alloc] init];
self->secureTextField.userInteractionEnabled = false;
self->secureTextField.tag = TAG_SCREEN_PROTECTION;
UIWindow *window = [UIApplication sharedApplication].keyWindow;
UIWindow *window = [[UIApplication sharedApplication] delegate].window;

[window makeKeyAndVisible];

[window.layer.superlayer addSublayer:self->secureTextField.layer];
[self->secureTextField.layer.sublayers.firstObject addSublayer:window.layer];
[self->secureTextField.layer.sublayers.lastObject addSublayer:window.layer];
}
[self->secureTextField setSecureTextEntry:isSecure];
});
Expand Down

0 comments on commit 2d742a5

Please sign in to comment.