55#import < AppKit/AppKit.h>
66#import < Contacts/Contacts.h>
77#import < CoreBluetooth/CoreBluetooth.h>
8+ #import < CoreGraphics/CoreGraphics.h>
89#import < CoreLocation/CoreLocation.h>
910#import < EventKit/EventKit.h>
1011#import < Foundation/Foundation.h>
@@ -202,7 +203,13 @@ bool HasOpenSystemPreferencesDialog() {
202203// Screen Capture access.
203204std::string ScreenAuthStatus () {
204205 std::string auth_status = kNotDetermined ;
205- if (@available (macOS 10.15 , *)) {
206+ if (@available (macOS 11 , *)) {
207+ if (CGPreflightScreenCaptureAccess ()) {
208+ auth_status = kAuthorized ;
209+ } else {
210+ auth_status = kDenied ;
211+ }
212+ } else if (@available (macOS 10.15 , *)) {
206213 auth_status = kDenied ;
207214 NSRunningApplication *runningApplication =
208215 NSRunningApplication .currentApplication ;
@@ -696,7 +703,9 @@ void AskForFullDiskAccess(const Napi::CallbackInfo &info) {
696703
697704// Request Screen Capture Access.
698705void AskForScreenCaptureAccess (const Napi::CallbackInfo &info) {
699- if (@available (macOS 10.15 , *)) {
706+ if (@available (macOS 11 , *)) {
707+ CGRequestScreenCaptureAccess ();
708+ } else if (@available (macOS 10.15 , *)) {
700709 // Tries to create a capture stream. This is necessary to add the app back
701710 // to the list in sysprefs if the user previously denied.
702711 // https://stackoverflow.com/questions/56597221/detecting-screen-recording-settings-on-macos-catalina
@@ -765,4 +774,4 @@ void AskForAccessibilityAccess(const Napi::CallbackInfo &info) {
765774 return exports;
766775}
767776
768- NODE_API_MODULE (permissions, Init)
777+ NODE_API_MODULE (permissions, Init)
0 commit comments