5
5
#import < AppKit/AppKit.h>
6
6
#import < Contacts/Contacts.h>
7
7
#import < CoreBluetooth/CoreBluetooth.h>
8
+ #import < CoreGraphics/CoreGraphics.h>
8
9
#import < CoreLocation/CoreLocation.h>
9
10
#import < EventKit/EventKit.h>
10
11
#import < Foundation/Foundation.h>
@@ -202,7 +203,13 @@ bool HasOpenSystemPreferencesDialog() {
202
203
// Screen Capture access.
203
204
std::string ScreenAuthStatus () {
204
205
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 , *)) {
206
213
auth_status = kDenied ;
207
214
NSRunningApplication *runningApplication =
208
215
NSRunningApplication .currentApplication ;
@@ -696,7 +703,9 @@ void AskForFullDiskAccess(const Napi::CallbackInfo &info) {
696
703
697
704
// Request Screen Capture Access.
698
705
void 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 , *)) {
700
709
// Tries to create a capture stream. This is necessary to add the app back
701
710
// to the list in sysprefs if the user previously denied.
702
711
// https://stackoverflow.com/questions/56597221/detecting-screen-recording-settings-on-macos-catalina
@@ -765,4 +774,4 @@ void AskForAccessibilityAccess(const Napi::CallbackInfo &info) {
765
774
return exports;
766
775
}
767
776
768
- NODE_API_MODULE (permissions, Init)
777
+ NODE_API_MODULE (permissions, Init)
0 commit comments