diff --git a/example/macos/Podfile.lock b/example/macos/Podfile.lock index 7d0dcd6..0dd970e 100644 --- a/example/macos/Podfile.lock +++ b/example/macos/Podfile.lock @@ -15,7 +15,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 - no_screenshot: fa5b394f299474b86373048f3a4c6e630d5ff029 + no_screenshot: 5aa748db902621ad390390274689c8f015d32709 PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367 diff --git a/example/macos/Runner.xcodeproj/project.pbxproj b/example/macos/Runner.xcodeproj/project.pbxproj index 1c883b4..a404d54 100644 --- a/example/macos/Runner.xcodeproj/project.pbxproj +++ b/example/macos/Runner.xcodeproj/project.pbxproj @@ -195,7 +195,6 @@ A9CC58A1EDA40E034D04800D /* Pods-RunnerTests.release.xcconfig */, 234B5FD704045AB80FD1910F /* Pods-RunnerTests.profile.xcconfig */, ); - name = Pods; path = Pods; sourceTree = ""; }; @@ -579,6 +578,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); + MACOSX_DEPLOYMENT_TARGET = 10.11; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; }; @@ -711,6 +711,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); + MACOSX_DEPLOYMENT_TARGET = 10.11; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; @@ -731,6 +732,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); + MACOSX_DEPLOYMENT_TARGET = 10.11; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; }; diff --git a/macos/Classes/NoScreenshotPlugin.swift b/macos/Classes/NoScreenshotPlugin.swift index 6255f0d..aba6b7e 100644 --- a/macos/Classes/NoScreenshotPlugin.swift +++ b/macos/Classes/NoScreenshotPlugin.swift @@ -74,10 +74,11 @@ public class NoScreenshotPlugin: NSObject, FlutterPlugin, FlutterStreamHandler { private func shotOff() { NoScreenshotPlugin.preventScreenShot = NoScreenshotPlugin.DISABLESCREENSHOT - print("Screenshot prevention activated.") + print("Screenshot and screen recording prevention activated.") + DispatchQueue.main.async { if let window = NSApplication.shared.windows.first { - window.sharingType = .none + window.sharingType = .none // Prevents both screenshots and screen recordings } } persistState() @@ -85,18 +86,19 @@ public class NoScreenshotPlugin: NSObject, FlutterPlugin, FlutterStreamHandler { private func shotOn() { NoScreenshotPlugin.preventScreenShot = NoScreenshotPlugin.ENABLESCREENSHOT - print("Screenshot prevention deactivated.") + print("Screenshot and screen recording prevention deactivated.") + DispatchQueue.main.async { if let window = NSApplication.shared.windows.first { - window.sharingType = .readOnly // or .full, depending on your needs + window.sharingType = .readOnly // Allows screenshots and screen recordings } } persistState() } private func startListening() { - // macOS does not provide a direct API for screenshot events, so we simulate this. - print("Start listening for screenshot.") + // macOS does not provide a direct API for detecting screen recording events, so we simulate this. + print("Start listening for screenshot and screen recording.") persistState() } @@ -108,7 +110,7 @@ public class NoScreenshotPlugin: NSObject, FlutterPlugin, FlutterStreamHandler { private func updateScreenshotState(isScreenshotBlocked: Bool) { DispatchQueue.main.async { if let window = NSApplication.shared.windows.first { - window.sharingType = isScreenshotBlocked ? .none : .readOnly // or .full + window.sharingType = isScreenshotBlocked ? .none : .readOnly } } print("Updated screenshot state to \(isScreenshotBlocked ? "Blocked" : "Unblocked")")