Prevent iOS from taking screen capture of app before going into background Prevent iOS from taking screen capture of app before going into background ios ios

Prevent iOS from taking screen capture of app before going into background


You are on the right track. This is Apple's recommended way to do this as noted in the iOS Application Programming Guide:

Remove sensitive information from views before moving to the background. When an application transitions to the background, the system takes a snapshot of the application’s main window, which it then presents briefly when transitioning your application back to the foreground. Before returning from your applicationDidEnterBackground: method, you should hide or obscure passwords and other sensitive personal information that might be captured as part of the snapshot.


Need to write the code in Application life cycle methods, here we are putting an imageView while the app animate to background :

-(void)applicationWillResignActive:(UIApplication *)application{    imageView = [[UIImageView alloc]initWithFrame:[self.window frame]];    [imageView setImage:[UIImage imageNamed:@"Splash_Screen.png"]];    [self.window addSubview:imageView];}

Here is the code to remove the imageView:

- (void)applicationDidBecomeActive:(UIApplication *)application{    if(imageView != nil) {        [imageView removeFromSuperview];        imageView = nil;    }}

It is working and properly tested.


I came across the same issue, and my research has lead me to the following answers:

  • set a blurry screen overlay before the app goes in the background and once the app becomes active remove this overlay

  • if it is iOS 7 or later you can use the functionignoreSnapshotOnNextApplicationLaunch

See in apple documentation:https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/occ/instm/UIApplication/ignoreSnapshotOnNextApplicationLaunch

I hope this helps somebody.


matomo