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:10 UTC
[cordova-plugin-device] 01/04: Initial checking, adding isiOSAppOnMac detection
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 b096d2fdfc423eefd2d148036b7e8dfdc6e26f2a
Author: stevepodell <st...@podell.com>
AuthorDate: Tue Oct 6 12:11:04 2020 -0700
Initial checking, adding isiOSAppOnMac detection
---
src/ios/CDVDevice.m | 18 +++++++++++++++---
www/device.js | 2 ++
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/src/ios/CDVDevice.m b/src/ios/CDVDevice.m
index de53533..643192b 100644
--- a/src/ios/CDVDevice.m
+++ b/src/ios/CDVDevice.m
@@ -53,7 +53,7 @@
{
NSUserDefaults* userDefaults = [NSUserDefaults standardUserDefaults];
static NSString* UUID_KEY = @"CDVUUID";
-
+
// Check user defaults first to maintain backwards compaitibility with previous versions
// which didn't user identifierForVendor
NSString* app_uuid = [userDefaults stringForKey:UUID_KEY];
@@ -69,7 +69,7 @@
[userDefaults setObject:app_uuid forKey:UUID_KEY];
[userDefaults synchronize];
}
-
+
return app_uuid;
}
@@ -92,7 +92,8 @@
@"version": [device systemVersion],
@"uuid": [self uniqueAppInstanceIdentifier:device],
@"cordova": [[self class] cordovaVersion],
- @"isVirtual": @([self isVirtual])
+ @"isVirtual": @([self isVirtual]),
+ @"isiOSAppOnMac": @([self isiOSAppOnMac])
};
}
@@ -112,4 +113,15 @@
#endif
}
+
+- (BOOL) isiOSAppOnMac
+{
+ if (@available(iOS 14.0, *)) {
+ return [NSProcessInfo processInfo].isiOSAppOnMac;
+ } else {
+ // Fallback on earlier versions
+ return false;
+ }
+}
+
@end
diff --git a/www/device.js b/www/device.js
index b05c0cb..75ef30e 100644
--- a/www/device.js
+++ b/www/device.js
@@ -43,6 +43,7 @@ function Device () {
this.manufacturer = null;
this.isVirtual = null;
this.serial = null;
+ this.isiOSAppOnMac = null;
var me = this;
@@ -59,6 +60,7 @@ function Device () {
me.cordova = buildLabel;
me.model = info.model;
me.isVirtual = info.isVirtual;
+ me.isiOSAppOnMac = info.isiOSAppOnMac || false;
me.manufacturer = info.manufacturer || 'unknown';
me.serial = info.serial || 'unknown';
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org