iOS 11: Is it possible to block screen recording?

I am publishing here the official response from Apple Developer Technical Support (DTS):

While there is no way to prevent screen recording, as part of iOS 11, there are new APIs on UIScreen that applications can use to know when the screen is being captured:

  • UIScreen.isCaptured Instance Property
  • UIScreenCapturedDidChange Notification Type Property

The contents of a screen can be recorded, mirrored, sent over AirPlay, or otherwise cloned to another destination. UIKit sends the UIScreenCapturedDidChange notification when the capture status of the screen changes.

The object of the notification is the UIScreen object whose isCaptured property changed. There is no userInfo dictionary. Your application can then handle this change and prevent your application content from being captured in whatever way is appropriate for your use.

HTH!


The feature is available on and above iOS11. Better keep it inside didFinishLaunchingWithOptions

Objective-C syntax

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  if (@available(iOS 11.0, *)) {
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(screenCaptureChanged) name:UIScreenCapturedDidChangeNotification object:nil];
    }

    return YES;
 }




-(void)screenCaptureChanged{

if (@available(iOS 11.0, *)) {

    BOOL isCaptured = [[UIScreen mainScreen] isCaptured];// will keep on checking for screen recorder if it is runnuning or not.

    if(isCaptured){

        UIView *colourView = [[UIView alloc]initWithFrame:self.window.frame];

        colourView.backgroundColor = [UIColor blackColor];

        colourView.tag = 1234;

        colourView.alpha = 0;

        [self.window makeKeyAndVisible];

        [self.window addSubview:colourView];

        // fade in the view

        [UIView animateWithDuration:0.5 animations:^{

            colourView.alpha = 1;

        }];

    }else{

        // grab a reference to our coloured view

        UIView *colourView = [self.window viewWithTag:1234];

        // fade away colour view from main view

        [UIView animateWithDuration:0.5 animations:^{

            colourView.alpha = 0;

        } completion:^(BOOL finished) {

            // remove when finished fading

            [colourView removeFromSuperview];

        }];

    }

} else {

    // Fallback on earlier versions

    // grab a reference to our coloured view

    UIView *colourView = [self.window viewWithTag:1234];

    if(colourView!=nil){

        // fade away colour view from main view

        [UIView animateWithDuration:0.5 animations:^{

            colourView.alpha = 0;

        } completion:^(BOOL finished) {

            // remove when finished fading

            [colourView removeFromSuperview];

        }];

    }

}

}

Tags:

Ios

Ios11