iOS Screen recording detection

旧时模样 提交于 2021-02-08 10:22:15

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/53425563/ios-screen-recording-detection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!