问题
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:
- Launch the app
- Start screen recorder using the apple screen recording option
- The screen recorder is detected
- Terminate the app
- Repeat the step 1 and 2
- 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