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:
UIScreen.mainScreen.isCaptured
returns NOPlease suggest
You should check for recording repeatedly.
I used this code and it worked for me. check it out: