简体   繁体   English

iOS屏幕录像检测

[英]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. 我试图检测是否为iOS 11的应用程序打开了屏幕捕获,以检测到该UIScreen.mainScreen.isCaptured属性用于检查是否已记录。

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. 对于第一次启动,当应用程序终止并再次启动时,它运行良好,尽管打开了屏幕截图,但API返回NO。

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 重复步骤1和2
  6. The screen recording is not detected, the API UIScreen.mainScreen.isCaptured returns NO 未检测到屏幕录像,API UIScreen.mainScreen.isCaptured返回“否”

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 https://gist.github.com/abhimuralidharan/8db55dff9023028867b719f251372bd7#file-screenrecordingdetector-m

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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