CGRequestScreenCaptureAccess()
and CGPreflightScreenCaptureAccess()
should return true
or false
depending on whether the app has screen recording permission. CGRequestScreenCaptureAccess()
will bring up a dialog if there is no permission. The dialog directs the user to the System Settings, where the permission can be set.
CGRequestScreenCaptureAccess()
returns immediately in any case. If it brings up a dialog, that happens from a separate process (Finder?) That dialog stays up even if the app quits before the dialog is dismissed.
Since CGRequestScreenCaptureAccess()
returns immediately, I tried tracking the permission state by setting up a timer to repeatedly call CGPreflightScreenCaptureAccess()
until the permission is set, but if it returned false
to begin with, it will continue to return false
, even if the app has been given permission for screen capture. Why is that?
When the permission to capture is set in the System Settings, a dialog says, "(App Name) may not be able to record the contents of your screen until it is quit." I imagine that is related to CGPreflightScreenCaptureAccess()
keeping returning false
. But why "may not be able"? When does the permission setting change take effect immediately? How can this be detected?