iOS 屏幕录制检测 [英] iOS Screen recording detection

查看:314
本文介绍了iOS 屏幕录制检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试检测 iOS 11 应用程序的屏幕捕获是否打开,为了检测这一点,UIScreen.mainScreen.isCaptured 属性用于检查它是否被记录.

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.

它在第一次启动时工作正常,当应用程序终止并再次启动时,尽管屏幕截图打开,但 API 返回 NO.

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.

代码:

//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
    }
  }
}

用例场景:

  1. 启动应用程序
  2. 使用苹果屏幕录制选项启动屏幕录制器
  3. 检测到屏幕录像机
  4. 终止应用
  5. 重复第 1 步和第 2 步
  6. 未检测到录屏,APIUIScreen.mainScreen.isCaptured返回NO

请推荐

推荐答案

你应该反复检查录音.

我使用了这段代码,它对我有用.看看:

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

https://gist.github.com/abhimuralidharan/8023028867b719f251372bd7#file-screenrecordingdetector-m"-screenrecordingdetector-m

这篇关于iOS 屏幕录制检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆