Skip to content

Commit 4f2d17c

Browse files
committed
build: bump minumum macOS to 10.13
1 parent 1b2e2f0 commit 4f2d17c

File tree

3 files changed

+40
-61
lines changed

3 files changed

+40
-61
lines changed

README.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,8 @@ Return Value Descriptions:
7171
**Notes:**
7272
* Access to `bluetooth` will always return a status of `authorized` prior to macOS 10.15, as the underlying API was not introduced until that version.
7373
* Access to `camera` and `microphone` will always return a status of `authorized` prior to macOS 10.14, as the underlying API was not introduced until that version.
74-
* Access to `contacts` will always return a status of `authorized` prior to macOS 10.11, as the underlying API was not introduced until that version.
7574
* Access to `input-monitoring` will always return a status of `authorized` prior to macOS 10.15, as the underlying API was not introduced until that version.
7675
* Access to `music-library` will always return a status of `authorized` prior to macOS 11.0, as the underlying API was not introduced until that version.
77-
* Access to `photos` will always return a status of `authorized` prior to macOS 10.13, as the underlying API was not introduced until that version.
7876
* Access to `screen` will always return a status of `authorized` prior to macOS 10.15, as the underlying API was not introduced until that version.
7977
* Access to `speech-recognition` will always return a status of `authorized` prior to macOS 10.15, as the underlying API was not introduced until that version.
8078

@@ -114,8 +112,6 @@ Your app’s `Info.plist` file must provide a value for the `NSContactsUsageDesc
114112
<string>Your reason for wanting to access the Contact store</string>
115113
```
116114

117-
**Note:** `status` will be resolved back as `authorized` prior to macOS 10.11, as the underlying API was not introduced until that version.
118-
119115
Example:
120116
```js
121117
const { askForContactsAccess } = require('node-mac-permissions')
@@ -350,10 +346,6 @@ Your app must provide an explanation for its use of the photo library using the
350346
<string>Your reason for wanting to access Photos</string>
351347
```
352348

353-
**Note:**
354-
355-
- `status` will be resolved back as `authorized` prior to macOS 10.13, as the underlying API was not introduced until that version.
356-
357349
Example:
358350

359351
```js

binding.gyp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
],
1919
'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ],
2020
"xcode_settings": {
21-
"MACOSX_DEPLOYMENT_TARGET": "10.10",
21+
"MACOSX_DEPLOYMENT_TARGET": "10.13",
2222
"SYSTEM_VERSION_COMPAT": 1,
2323
"OTHER_CPLUSPLUSFLAGS": ["-std=c++14", "-stdlib=libc++"],
2424
"OTHER_LDFLAGS": [

permissions.mm

Lines changed: 39 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -339,17 +339,15 @@ bool HasOpenSystemPreferencesDialog() {
339339
// Returns a status indicating whether or not the user has authorized Photos
340340
// access.
341341
std::string PhotosAuthStatus() {
342-
if (@available(macOS 10.13, *)) {
343-
switch ([PHPhotoLibrary authorizationStatus]) {
344-
case PHAuthorizationStatusAuthorized:
345-
return kAuthorized;
346-
case PHAuthorizationStatusDenied:
347-
return kDenied;
348-
case PHAuthorizationStatusRestricted:
349-
return kRestricted;
350-
default:
351-
return kNotDetermined;
352-
}
342+
switch ([PHPhotoLibrary authorizationStatus]) {
343+
case PHAuthorizationStatusAuthorized:
344+
return kAuthorized;
345+
case PHAuthorizationStatusDenied:
346+
return kDenied;
347+
case PHAuthorizationStatusRestricted:
348+
return kRestricted;
349+
default:
350+
return kNotDetermined;
353351
}
354352

355353
return kAuthorized;
@@ -431,23 +429,18 @@ bool HasOpenSystemPreferencesDialog() {
431429
Napi::ThreadSafeFunction ts_fn = Napi::ThreadSafeFunction::New(
432430
env, Napi::Function::New(env, NoOp), "contactsCallback", 0, 1);
433431

434-
if (@available(macOS 10.11, *)) {
435-
__block Napi::ThreadSafeFunction tsfn = ts_fn;
436-
CNContactStore *store = [CNContactStore new];
437-
[store requestAccessForEntityType:CNEntityTypeContacts
438-
completionHandler:^(BOOL granted, NSError *error) {
439-
auto callback = [=](Napi::Env env, Napi::Function js_cb,
440-
const char *granted) {
441-
deferred.Resolve(Napi::String::New(env, granted));
442-
};
443-
tsfn.BlockingCall(granted ? "authorized" : "denied",
444-
callback);
445-
tsfn.Release();
446-
}];
447-
} else {
448-
ts_fn.Release();
449-
deferred.Resolve(Napi::String::New(env, kAuthorized));
450-
}
432+
__block Napi::ThreadSafeFunction tsfn = ts_fn;
433+
CNContactStore *store = [CNContactStore new];
434+
[store
435+
requestAccessForEntityType:CNEntityTypeContacts
436+
completionHandler:^(BOOL granted, NSError *error) {
437+
auto callback = [=](Napi::Env env, Napi::Function js_cb,
438+
const char *granted) {
439+
deferred.Resolve(Napi::String::New(env, granted));
440+
};
441+
tsfn.BlockingCall(granted ? "authorized" : "denied", callback);
442+
tsfn.Release();
443+
}];
451444

452445
return deferred.Promise();
453446
}
@@ -594,33 +587,27 @@ void AskForFullDiskAccess(const Napi::CallbackInfo &info) {
594587
Napi::ThreadSafeFunction ts_fn = Napi::ThreadSafeFunction::New(
595588
env, Napi::Function::New(env, NoOp), "photosCallback", 0, 1);
596589

597-
if (@available(macOS 10.13, *)) {
598-
std::string auth_status = PhotosAuthStatus();
599-
600-
if (auth_status == kNotDetermined) {
601-
__block Napi::ThreadSafeFunction tsfn = ts_fn;
602-
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
603-
auto callback = [=](Napi::Env env, Napi::Function js_cb,
604-
const char *granted) {
605-
deferred.Resolve(Napi::String::New(env, granted));
606-
};
607-
tsfn.BlockingCall(
608-
status == PHAuthorizationStatusAuthorized ? "authorized" : "denied",
609-
callback);
610-
tsfn.Release();
611-
}];
612-
} else if (auth_status == kDenied) {
613-
OpenPrefPane("Privacy_Photos");
590+
std::string auth_status = PhotosAuthStatus();
591+
if (auth_status == kNotDetermined) {
592+
__block Napi::ThreadSafeFunction tsfn = ts_fn;
593+
[PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
594+
auto callback = [=](Napi::Env env, Napi::Function js_cb,
595+
const char *granted) {
596+
deferred.Resolve(Napi::String::New(env, granted));
597+
};
598+
tsfn.BlockingCall(status == PHAuthorizationStatusAuthorized ? "authorized"
599+
: "denied",
600+
callback);
601+
tsfn.Release();
602+
}];
603+
} else if (auth_status == kDenied) {
604+
OpenPrefPane("Privacy_Photos");
614605

615-
ts_fn.Release();
616-
deferred.Resolve(Napi::String::New(env, kDenied));
617-
} else {
618-
ts_fn.Release();
619-
deferred.Resolve(Napi::String::New(env, auth_status));
620-
}
606+
ts_fn.Release();
607+
deferred.Resolve(Napi::String::New(env, kDenied));
621608
} else {
622609
ts_fn.Release();
623-
deferred.Resolve(Napi::String::New(env, kAuthorized));
610+
deferred.Resolve(Napi::String::New(env, auth_status));
624611
}
625612

626613
return deferred.Promise();

0 commit comments

Comments
 (0)