From 2e4bb8471d80a341c2439ef6d6b0bcd929e72abc Mon Sep 17 00:00:00 2001 From: evgeny Date: Tue, 25 Dec 2018 23:36:22 +0300 Subject: upd --- index.mm | 11 +++++++---- package.json | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/index.mm b/index.mm index 6599ff7..423af50 100644 --- a/index.mm +++ b/index.mm @@ -34,6 +34,11 @@ std::string ConvertAuthorizationStatus(AVAuthorizationStatus status) { } } +bool isMojave() { + NSOperatingSystemVersion minimumSupportedOSVersion = { .majorVersion = 10, .minorVersion = 14, .patchVersion = 0 }; + return [NSProcessInfo.processInfo isOperatingSystemAtLeastVersion:minimumSupportedOSVersion]; +} + struct Baton { uv_work_t request; Persistent callback; @@ -96,9 +101,7 @@ void AskForMediaAccess(const v8::FunctionCallbackInfo& args) { Local cbFunc = Local::Cast(args[1]); if (auto type = ParseMediaType(mediaType)) { - NSOperatingSystemVersion minimumSupportedOSVersion = { .majorVersion = 10, .minorVersion = 14, .patchVersion = 0 }; - BOOL isSupported = [NSProcessInfo.processInfo isOperatingSystemAtLeastVersion:minimumSupportedOSVersion]; - if (isSupported) { + if (isMojave()) { Baton *baton = new Baton; baton->type = type; baton->callback.Reset(isolate, cbFunc); @@ -133,7 +136,7 @@ void GetMediaAccessStatus(const v8::FunctionCallbackInfo& args) { std::string mediaType(*mediaTypeValue); if (auto type = ParseMediaType(mediaType)) { - if (@available(macOS 10.14, *)) { + if (isMojave()) { args.GetReturnValue().Set(String::NewFromUtf8(isolate, ConvertAuthorizationStatus( [AVCaptureDevice authorizationStatusForMediaType:type]).c_str())); } else { diff --git a/package.json b/package.json index 9cedefe..da46883 100644 --- a/package.json +++ b/package.json @@ -11,5 +11,5 @@ "install": "node-gyp rebuild", "test": "node index.js" }, - "version": "1.0.1" + "version": "1.0.2" } -- cgit v1.2.3