skip to Main Content

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

2

Answers


  1. Chosen as BEST ANSWER

    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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search