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

3

2 Answers 2

7

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)
  }
}
Sign up to request clarification or add additional context in comments.

4 Comments

Have you try this and work ?
yes it's working well
This method will not allow you to upload the app to the app store.
@kunjkanani app already uploaded apps.apple.com/us/app/privilege/id1632963488
-5

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.

1 Comment

I'm asking about iOS not android

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.