ishahak
ishahak

Reputation: 6795

iOS 11: Is it possible to block screen recording?

I have an app which plays video, and I don't want people to use the new iOS-11 feature to record these videos and make them public. That feature is described here.

I could not find any documentation regarding an option for my app to prevent users from recording it.

Can anybody please guide me to anything related to this?

Thank you!

Upvotes: 6

Views: 6084

Answers (2)

Ankit Aman
Ankit Aman

Reputation: 1009

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];

        }];

    }

}

}

Upvotes: 3

ishahak
ishahak

Reputation: 6795

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:

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!

Upvotes: 15

Related Questions