You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by er...@apache.org on 2022/04/06 01:30:13 UTC

[cordova-plugin-device] 04/04: Adds isiOSAppOnMac detection Rebased, and includes the suggestion from erisu

This is an automated email from the ASF dual-hosted git repository.

erisu pushed a commit to branch feat/detect-apple-silicon
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-device.git

commit 396e8c7fd89f882fe15fc3b1b87311b6656748cb
Author: stevepodell <st...@podell.com>
AuthorDate: Mon Apr 4 09:35:00 2022 -0700

    Adds isiOSAppOnMac detection
    Rebased, and includes the suggestion from erisu
---
 README.md           |  4 ++--
 src/osx/CDVDevice.m | 11 ++++++++++-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index 5a9cf50..ac8cacf 100644
--- a/README.md
+++ b/README.md
@@ -297,8 +297,8 @@ As of Android 9, the underlying native API that powered the `uuid` property is d
 
 ## device.isiOSAppOnMac
 
-Is the iOS app running on the Mac desktop? Will only return true on a Mac with an ARM64 processor (Apple Silicon).
-Returns false for all other platforms.
+The iOS app is running on the Mac desktop (Apple Silicon ARM64 processor, M1 or newer). 
+This parameter is only returned for iOS V14.0 or later, and is not returned for Android devices.
 
 ```js
 var boolean = device.isiOSAppOnMac;
diff --git a/src/osx/CDVDevice.m b/src/osx/CDVDevice.m
index 9e2d689..0cef13a 100644
--- a/src/osx/CDVDevice.m
+++ b/src/osx/CDVDevice.m
@@ -37,7 +37,6 @@
     return modelVersion;
 }
 
-
 - (NSString*) getSerialNr {
     NSString* serialNr;
     io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"));
@@ -101,6 +100,7 @@
     devProps[@"cordova"] = [[self class] cordovaVersion];
     devProps[@"serial"] = [self getSerialNr];
     devProps[@"isVirtual"] = @NO;
+    devProps[@"isiOSAppOnMac"]: [self isiOSAppOnMac];
 
     NSDictionary* devReturn = [NSDictionary dictionaryWithDictionary:devProps];
     return devReturn;
@@ -110,4 +110,13 @@
     return CDV_VERSION;
 }
 
++ (BOOL) isiOSAppOnMac {
+    if (@available(iOS 14.0, *)) {
+        return [NSProcessInfo processInfo].isiOSAppOnMac;
+    } else {
+        // Fallback on earlier versions and platforms
+        return false;
+    }
+}
+
 @end


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org