Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FB14920414: Add API to detect whether the screen is captured (recorded, shared, or mirrored) #546

Open
sindresorhus opened this issue Aug 25, 2024 · 2 comments

Comments

@sindresorhus
Copy link
Member

  • Date: 2024-08-26
  • Resolution: Open
  • Area: AppKit
  • OS: macOS 14.6
  • Type: Suggestion

Description

macOS needs a public API to detect if the screen is being observed (recorded, shared, or mirrored). iOS already offers this with UIScreen.isCaptured. macOS should have a similar capability to ensure consistency across platforms and improve user privacy.

I assume system notifications already use an internal API for this as they have a checkbox called "Allow notifications when mirroring or sharing the display".

Use Cases:

  • Sensitive Content Protection: Apps handling confidential or sensitive information can hide or blur content when the screen is being captured, preventing unintended exposure. For example, a calendar app could have a setting to hide event titles when the screen is captured, to avoid leaking private details on a screencast.
  • Fullscreen Notifications: Apps that show fullscreen alerts can suppress them when the screen is recorded or mirrored, ensuring privacy during sensitive operations.

Proposed API:

extension NSScreen {
	var isCaptured: Bool {}
}

I looked through the private headers on macOS and found that there already is a private property for this called CGSIsScreenWatcherPresent. So the functionality seems to already exist and just needs to be exposed.

@samhenrigold
Copy link

samhenrigold commented Oct 29, 2024

https://developer.apple.com/documentation/swiftui/environmentvalues/isscenecaptured#

Could you tap into this? Even if it means hosting an invisible SwiftUI view?

@sindresorhus
Copy link
Member Author

Not available for macOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants