Skip to content

Commit

Permalink
fix(ios, deviceType): support iOS-compiled app running on macOS (#1181)
Browse files Browse the repository at this point in the history
* run time check for iOS app running on macOS.

* Fix issue with iOS version detection. @avaliable has to be in a stand along if statement.

Co-authored-by: John Schember <jschember@monetra.com>
  • Loading branch information
user-none and John Schember committed Mar 17, 2021
1 parent 94ebdf4 commit 3ff676c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ios/RNDeviceInfo/RNDeviceInfo.m
Expand Up @@ -111,7 +111,16 @@ - (DeviceType) getDeviceType
{
switch ([[UIDevice currentDevice] userInterfaceIdiom]) {
case UIUserInterfaceIdiomPhone: return DeviceTypeHandset;
case UIUserInterfaceIdiomPad: return TARGET_OS_MACCATALYST ? DeviceTypeDesktop : DeviceTypeTablet;
case UIUserInterfaceIdiomPad:
if (TARGET_OS_MACCATALYST) {
return DeviceTypeDesktop;
}
if (@available(iOS 14.0, *)) {
if ([NSProcessInfo processInfo].isiOSAppOnMac) {
return DeviceTypeDesktop;
}
}
return DeviceTypeTablet;
case UIUserInterfaceIdiomTV: return DeviceTypeTv;
case UIUserInterfaceIdiomMac: return DeviceTypeDesktop;
default: return DeviceTypeUnknown;
Expand Down

0 comments on commit 3ff676c

Please sign in to comment.