1

I've got an education flutter iOS app. and I want to prevent users to take screenshots or screen records on a specific screen and how to make it

I'm trying many solutions here but no one is working

as attached below, it is a screen record form my iPhone from another app it still records till I reach to specific screen and push me back and showing me this alert dialog how to achieve this feature

Screen Record

  • Does this answer your question? [How to disable screen Recording in iOS app](https://stackoverflow.com/questions/53880491/how-to-disable-screen-recording-in-ios-app) – timbre timbre May 25 '22 at 20:45
  • Does this answer your question? [Prevent screen capture in an iOS app](https://stackoverflow.com/questions/18680028/prevent-screen-capture-in-an-ios-app) – Andrew May 25 '22 at 21:56
  • no, I'm trying both and not working – Saayeed M Daawoud May 26 '22 at 05:40

2 Answers2

5

Actually, APP Store Prevent this feature which is disable screenshot so we can work around to do this. my solution was to make user make an screen shot but with no data. I achieve it by this simple code


import UIKit
import Flutter
import FirebaseCore

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  private var textField = UITextField()
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    self.window.makeSecure()
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
  // Screenshot Prevent Functions
 

      // <Add>
  override func applicationWillResignActive(
    _ application: UIApplication
  ) {
    self.window.isHidden = true;
  }
  override func applicationDidBecomeActive(
    _ application: UIApplication
  ) {
    self.window.isHidden = false;
  }

  
}
  extension UIWindow {
   func makeSecure() {
    let field = UITextField()
    field.isSecureTextEntry = true
    self.addSubview(field)
    field.centerYAnchor.constraint(equalTo: self.centerYAnchor).isActive = true
    field.centerXAnchor.constraint(equalTo: self.centerXAnchor).isActive = true
    self.layer.superlayer?.addSublayer(field.layer)
    field.layer.sublayers?.first?.addSublayer(self.layer)
  }
}
-2

Use this if you don't want users to take screenshots in your app. flutter_windowmanager

By using this package, you can add many more functionality like blur app when its in background, force full screen, dismiss keyguard.

Read the dicumentation for more info.