iOS Hardware type 对应手机机型名称
+ (NSString *)gleGetMobileModel {
struct utsname systemInfo;
uname(&systemInfo);
NSString *platform = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
// iPhone
if ([platform isEqualToString:@"iPhone1,1"]) return @"iPhone";
if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone 3G";
if ([platform isEqualToString:@"iPhone2,1"]) return @"iPhone 3GS";
if ([platform isEqualToString:@"iPhone3,1"]) return @"iPhone 4";
if ([platform isEqualToString:@"iPhone3,2"]) return @"iPhone 4";
if ([platform isEqualToString:@"iPhone3,3"]) return @"iPhone 4";
if ([platform isEqualToString:@"iPhone4,1"]) return @"iPhone 4S";
// iPhone 5 | iPhone 5S | iPhone 5c
if ([platform isEqualToString:@"iPhone5,1"]) return @"iPhone 5";
if ([platform isEqualToString:@"iPhone5,2"]) return @"iPhone 5";
if ([platform isEqualToString:@"iPhone5,3"]) return @"iPhone 5c";
if ([platform isEqualToString:@"iPhone5,4"]) return @"iPhone 5c";
if ([platform isEqualToString:@"iPhone6,1"]) return @"iPhone 5S";
if ([platform isEqualToString:@"iPhone6,2"]) return @"iPhone 5S";
// iPhone 6 | iPhone 6P | iPhone 6S | iPhone 6SP
if ([platform isEqualToString:@"iPhone7,2"]) return @"iPhone 6";
if ([platform isEqualToString:@"iPhone7,1"]) return @"iPhone 6 Plus";
if ([platform isEqualToString:@"iPhone8,1"]) return @"iPhone 6S";
if ([platform isEqualToString:@"iPhone8,2"]) return @"iPhone 6S Plus";
// iPhone SE
if ([platform isEqualToString:@"iPhone8,3"]) return @"iPhone SE";
if ([platform isEqualToString:@"iPhone8,4"]) return @"iPhone SE";
// iPhone 7 | iPhone 7P
if ([platform isEqualToString:@"iPhone9,1"]) return @"iPhone 7";
if ([platform isEqualToString:@"iPhone9,2"]) return @"iPhone 7 Plus";
if ([platform isEqualToString:@"iPhone9,3"]) return @"iPhone 7";
if ([platform isEqualToString:@"iPhone9,4"]) return @"iPhone 7 Plus";
// iPhone 8 | iPhone 8P
if ([platform isEqualToString:@"iPhone10,1"]) return @"iPhone 8";
if ([platform isEqualToString:@"iPhone10,4"]) return @"iPhone 8";
if ([platform isEqualToString:@"iPhone10,2"]) return @"iPhone 8 Plus";
if ([platform isEqualToString:@"iPhone10,5"]) return @"iPhone 8 Plus";
// iPhone X
if ([platform isEqualToString:@"iPhone10,3"]) return @"iPhone X";
if ([platform isEqualToString:@"iPhone10,6"]) return @"iPhone X";
// iPhone XR | iPhone XS | iPhone XS_Max
if ([platform isEqualToString:@"iPhone11,8"]) return @"iPhone XR";
if ([platform isEqualToString:@"iPhone11,2"]) return @"iPhone XS";
if ([platform isEqualToString:@"iPhone11,4"]) return @"iPhone XS Max China";
if ([platform isEqualToString:@"iPhone11,6"]) return @"iPhone XS Max";
// iPhone 11 | iPhone 11 Pro | iPhone 11 Pro Max
if ([platform isEqualToString:@"iPhone12,1"]) return @"iPhone 11";
if ([platform isEqualToString:@"iPhone12,3"]) return @"iPhone 11 Pro";
if ([platform isEqualToString:@"iPhone12,5"]) return @"iPhone 11 Pro Max";
// 新版SE2
if ([platform isEqualToString:@"iPhone12,8"]) return @"iPhone SE 2nd Gen";
// iPhone 12
if ([platform isEqualToString:@"iPhone13,1"]) return @"iPhone 12 Mini";
if ([platform isEqualToString:@"iPhone13,2"]) return @"iPhone 12";
if ([platform isEqualToString:@"iPhone13,3"]) return @"iPhone 12 Pro";
if ([platform isEqualToString:@"iPhone13,4"]) return @"iPhone 12 Pro Max";
// iPhone 13
if ([platform isEqualToString:@"iPhone14,2"]) return @"iPhone 13 Pro";
if ([platform isEqualToString:@"iPhone14,3"]) return @"iPhone 13 Pro Max";
if ([platform isEqualToString:@"iPhone14,4"]) return @"iPhone 13 Mini";
if ([platform isEqualToString:@"iPhone14,5"]) return @"iPhone 13";
// .....
// iPod Touch
if ([platform isEqualToString:@"iPod1,1"]) return @"iPod_Touch";
if ([platform isEqualToString:@"iPod2,1"]) return @"iPod_Touch_2";
if ([platform isEqualToString:@"iPod3,1"]) return @"iPod_Touch_3";
if ([platform isEqualToString:@"iPod4,1"]) return @"iPod_Touch_4";
if ([platform isEqualToString:@"iPod5,1"]) return @"iPod_Touch_5";
if ([platform isEqualToString:@"iPod7,1"]) return @"iPod_Touch_6";
// iPad
if ([platform isEqualToString:@"iPad1,1"]) return @"iPad";
if ([platform isEqualToString:@"iPad2,1"]) return @"iPad_2 (WiFi)";
if ([platform isEqualToString:@"iPad2,2"]) return @"iPad_2 (GSM)";
if ([platform isEqualToString:@"iPad2,3"]) return @"iPad_2 (CDMA)";
if ([platform isEqualToString:@"iPad2,4"]) return @"iPad_2";
if ([platform isEqualToString:@"iPad3,1"]) return @"iPad_3";
if ([platform isEqualToString:@"iPad3,2"]) return @"iPad_3";
if ([platform isEqualToString:@"iPad3,3"]) return @"iPad_3";
if ([platform isEqualToString:@"iPad3,4"]) return @"iPad_4 (WiFi)";
if ([platform isEqualToString:@"iPad3,5"]) return @"iPad_4";
if ([platform isEqualToString:@"iPad3,6"]) return @"iPad_4";
if ([platform isEqualToString:@"iPad6,11"]) return @"iPad_5";
if ([platform isEqualToString:@"iPad6,12"]) return @"iPad_5";
if ([platform isEqualToString:@"iPad7,5"]) return @"iPad_6";
if ([platform isEqualToString:@"iPad7,6"]) return @"iPad_6";
// iPad_Air
if ([platform isEqualToString:@"iPad4,1"]) return @"iPad_Air";
if ([platform isEqualToString:@"iPad4,2"]) return @"iPad_Air";
if ([platform isEqualToString:@"iPad4,3"]) return @"iPad_Air";
if ([platform isEqualToString:@"iPad5,3"]) return @"iPad_Air_2";
if ([platform isEqualToString:@"iPad5,4"]) return @"iPad_Air_2";
// iPad_mini
if ([platform isEqualToString:@"iPad2,5"]) return @"iPad_mini";
if ([platform isEqualToString:@"iPad2,6"]) return @"iPad_mini";
if ([platform isEqualToString:@"iPad2,7"]) return @"iPad_mini";
// iPad_mini 2
if ([platform isEqualToString:@"iPad4,4"]) return @"iPad_mini_2";
if ([platform isEqualToString:@"iPad4,5"]) return @"iPad_mini_2";
if ([platform isEqualToString:@"iPad4,6"]) return @"iPad_mini_2";
// iPad_mini 3
if ([platform isEqualToString:@"iPad4,7"]) return @"iPad_mini_3";
if ([platform isEqualToString:@"iPad4,8"]) return @"iPad_mini_3";
if ([platform isEqualToString:@"iPad4,9"]) return @"iPad_mini_3";
// iPad_mini 4
if ([platform isEqualToString:@"iPad5,1"]) return @"iPad_mini_4";
if ([platform isEqualToString:@"iPad5,2"]) return @"iPad_mini_4";
// iPad Pro(9.7)
if ([platform isEqualToString:@"iPad6,3"]) return @"iPad Pro(9.7)";
if ([platform isEqualToString:@"iPad6,4"]) return @"iPad Pro(9.7)";
// iPad Pro(10.5)
if ([platform isEqualToString:@"iPad7,3"]) return @"iPad Pro(10.5)";
if ([platform isEqualToString:@"iPad7,4"]) return @"iPad Pro(10.5)";
// iPad Pro(11)
if ([platform isEqualToString:@"iPad8,1"]) return @"iPad Pro(11)";
if ([platform isEqualToString:@"iPad8,2"]) return @"iPad Pro(11)";
if ([platform isEqualToString:@"iPad8,3"]) return @"iPad Pro(11)";
if ([platform isEqualToString:@"iPad8,4"]) return @"iPad Pro(11)";
// iPad Pro(12.9)
if ([platform isEqualToString:@"iPad6,7"]) return @"iPad Pro(12.9)";
if ([platform isEqualToString:@"iPad6,8"]) return @"iPad Pro(12.9)";
// iPad Pro_2(12.9)
if ([platform isEqualToString:@"iPad7,1"]) return @"iPad Pro_2(12.9)";
if ([platform isEqualToString:@"iPad7,2"]) return @"iPad Pro_2(12.9)";
// iPad Pro_3(12.9)
if ([platform isEqualToString:@"iPad8,5"]) return @"iPad Pro_3(12.9)";
if ([platform isEqualToString:@"iPad8,6"]) return @"iPad Pro_3(12.9)";
if ([platform isEqualToString:@"iPad8,7"]) return @"iPad Pro_3(12.9)";
if ([platform isEqualToString:@"iPad8,8"]) return @"iPad Pro_3(12.9)";
// 模拟器
if ([platform isEqualToString:@"i386"]) return @"Simulator_i386";
if ([platform isEqualToString:@"x86_64"]) return @"Simulator_x86_64";
DEBUGLog(@"查询设备localizeModel:%@", [UIDevice currentDevice].localizedModel);
return platform;
}
网友评论