Skip to content

disablePreventScreenshot() leaves residual overlay causing black screen with SFSafariViewController (v1.5.1) #11

Description

@smcaman
  • Environment:
    iOS, Flutter app, ScreenProtectorKit 1.5.1 via CocoaPods, Using it in flutter through method channel

     [✓] Flutter (Channel stable, 3.41.2, on macOS 26.2 25C56 darwin-arm64, locale en-IN)
     [✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0-rc1)
     [✓] Xcode - develop for iOS and macOS (Xcode 26.2)
     [✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
     ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
     [✓] Connected device (3 available)
     [✓] Network resources
    
  • Steps to reproduce:
    Call enabledPreventScreenshot()
    Call disablePreventScreenshot()
    Present SFSafariViewController (via ChromeSafariBrowser / flutter_inappwebview)
    Dismiss the Safari view controller
    Black screen appears — Flutter view doesn't redraw

  • Workaround:
    Pinning to 1.4.2 resolves the issue

  • Code:
    // Initialize Flutter method channel for secure screenshot control
    let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
    methodChannel = FlutterMethodChannel(name: "secureChannel", binaryMessenger: controller.binaryMessenger)
    screenProtectorKit = ScreenProtectorKit(window: window ?? UIWindow())

      // Configure prevention (initial setup)
      screenProtectorKit?.configurePreventionScreenshot()
    
      methodChannel?.setMethodCallHandler { [weak self] (call, result) in
          guard let self = self else { return }
          switch call.method {
              case "disableTakingScreenshot":
                  self.screenProtectorKit?.enabledPreventScreenshot()
                  result(true)
              case "enableTakingScreenshot":
                  self.screenProtectorKit?.disablePreventScreenshot()
                  result(true)
              default:
                  result(FlutterMethodNotImplemented)
          }
      }
    

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions