简体   繁体   中英

iOS Screen recording detection

I tried to detect if screen capture is on for the application for iOS 11, to detect this the UIScreen.mainScreen.isCaptured property is used to check if it is recorded.

It works fine for the first launch, when the app is terminated and launched again, then the API returns NO though the screen capture is on.

Code:

//In viewWillAppear block

__block ViewController *weakSelf = self;
  [NSTimer scheduledTimerWithTimeInterval:2.0 repeats:YES block:^(NSTimer * _Nonnull timer) {
    [weakSelf screenCaptureDetection];
  }];

- (void) screenCaptureDetection {
  if (@available(iOS 11.0, *)) {
    for (UIScreen *screen in [UIScreen screens]) {
      if([screen performSelector:@selector(isCaptured)]){
      //Detected YES
    }
  }
}

Use case scenario:

  1. Launch the app
  2. Start screen recorder using the apple screen recording option
  3. The screen recorder is detected
  4. Terminate the app
  5. Repeat the step 1 and 2
  6. The screen recording is not detected, the API UIScreen.mainScreen.isCaptured returns NO

Please suggest

You should check for recording repeatedly.

I used this code and it worked for me. check it out:

https://gist.github.com/abhimuralidharan/8db55dff9023028867b719f251372bd7#file-screenrecordingdetector-m

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM