Screenshot restriction in iOS Native

i have a requirement where we need to restrict the user in taking the screen shot. as of now iam using this code  NotificationCenter.default.addObserver(self, selector: #selector(didDetectScreenshot), name: UIApplication.userDidTakeScreenshotNotification, object: nil)

This is triggered after taking the screenshot.

Is there any possibility to completely restrict in taking the screenshot.

Replies

AFAIK, there is no direct way to do it. And even if you did it, user could still take a photo with another camera. So, what's the exact goal ?

Some solutions require to work at the image level, doing some frame interleaving, pretty complex.

You could try to show hide overlay at a very rapid pace, which could blur the screenshot.

Have a look at this thread:

https://developer.apple.com/forums/thread/123725

You have also probably seen this:

https://betterprogramming.pub/how-to-prevent-screen-capture-at-ios-14-1f01173c31c0

But it just warns users, do not prevent screenshots.

  • The Goal is to restrict the user with in a mobile app.

    I tried with the blur image , but I don't find any resource to replace the screenshot with the blur image.

    This is the code i tried for blur image

      @objc private func didDetectScreenshot() {           var images: PHFetchResult!

        let allPhotosOptions = PHFetchOptions()

        allPhotosOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: true)]

        images = PHAsset.fetchAssets(with: PHAssetMediaType.image, options: allPhotosOptions)     let image1 = images.lastObject     let manager = PHImageManager.default()           let option = PHImageRequestOptions()           var image = UIImage()           option.isSynchronous = true     manager.requestImage(for: image1!, targetSize: CGSize(width: 100, height: 100), contentMode: .aspectFit, options: option, resultHandler: {(result, info)->Void in             image = result!       let blurimage = self.blurEffect(image: image)         *** After this i Tried to found the resource to replace the Screenshot in Gallery with Blur image, But i don't find anything related to that, Please provide me the solutions for this ****       }           }) }

    Thank you

Add a Comment