Is there any way to disable "screenshots" on iOS?

In my app I want to disable taking screenshots on confidential information. Is there any way to do that?

Replies

In your AppDelegate:


    func applicationWillResignActive(_ application: UIApplication) {
        UIApplication.shared.ignoreSnapshotOnNextApplicationLaunch()
    }


ignoreSnapshotOnNextApplicationLaunch()


Prevents the app from using the recent snapshot image during the next launch cycle.


As part of the state preservation process, UIKit captures your app’s user interface and stores it in an image file.


When your app is relaunched, the system displays this snapshot image in place of your app’s default launch image to preserve the notion that your app was still running.


If you feel that the snapshot cannot correctly reflect your app’s user interface when your app is relaunched, call this method to let UIKit know that it should use your app’s default launch image instead of the snapshot.


You must call this method from within the code you use to preserve your app’s state.

In addtion to ManuelMB's example that may help keep honest users honest, pls. reference the MLT links below.


Just remember that there is nothing your app can do to prevent a user pointing a camera at the device and taking a picture of any screen.


Rule is if you don't want confidential info out in the wild, don't put it there.

No way to disable the ability to take screenshots. We can detect in the app when a screenshot is taken and post the detection we can delete the last saved image.


Not going in details but just giving some pointers..we can detect when a screenshot is taken sign the below code. Once the detection is done..we can either delete the last image in Potos or edit to obscure the content.


Objective C


NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];

[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationUserDidTakeScreenshotNotification

object:nil

queue:mainQueue

usingBlock:^(NSNotification *note) {

// executes after screenshot/

//Write code here to delete/obscure the last image from photos

}];

Swift

NotificationCenter.default.addObserver(

forName: UIApplication.userDidTakeScreenshotNotification,

object: nil,

queue: .main) { notification in

// executes after screenshot

//Write code here to delete/obscure the last image from photos


}