最近更新并获取了下2020年初最新iOS设备型号
包括iPad, iPod touch, iPad Air, iPad Mini, iPhone
- (NSString*)deviceModelName {
struct utsname systemInfo;
uname(&systemInfo);
NSString * deviceString = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
if ([deviceString hasPrefix:@"iPhone"]) {
if ([deviceString isEqualToString:kDeviceModelIPhone1G]) return @"iPhone1";
else if ([deviceString isEqualToString:kDeviceModelIPhone3G]) return @"iPhone3";
else if ([deviceString isEqualToString:kDeviceModelIPhone3GS]) return @"iPhone3GS";
else if ([deviceString isEqualToString:kDeviceModelIPhone4] ||
[deviceString isEqualToString:kDeviceModelIPhone4_1]) return @"iPhone4";
else if ([deviceString isEqualToString:kDeviceModelIPhone4S]) return @"iPhone4S";
else if ([deviceString isEqualToString:kDeviceModelIPhone5] ||
[deviceString isEqualToString:kDeviceModelIPhone5_1]) return @"iPhone5";
else if ([deviceString isEqualToString:kDeviceModelIPhone5C] ||
[deviceString isEqualToString:kDeviceModelIPhone5C_1]) return @"iPhone5C";
else if ([deviceString isEqualToString:kDeviceModelIPhone5S] ||
[deviceString isEqualToString:kDeviceModelIPhone5S_1]) return @"iPhone5S";
else if ([deviceString isEqualToString:kDeviceModelIPhone6]) return @"iPhone6";
else if ([deviceString isEqualToString:kDeviceModelIPhone6P]) return @"iPhone6 plus";
else if ([deviceString isEqualToString:kDeviceModelIPhone6S]) return @"iPhone6S";
else if ([deviceString isEqualToString:kDeviceModelIPhone6SP]) return @"iPhone6S plus";
else if ([deviceString isEqualToString:kDeviceModelIPhoneSE]) return @"iPhoneSE";
else if ([deviceString isEqualToString:kDeviceModelIPhone7] ||
[deviceString isEqualToString:kDeviceModelIPhone7_1]) return @"iPhone7";
else if ([deviceString isEqualToString:kDeviceModelIPhone7P] ||
[deviceString isEqualToString:kDeviceModelIPhone7P_1]) return @"iPhone7 plus";
else if ([deviceString isEqualToString:kDeviceModelIPhone8] ||
[deviceString isEqualToString:kDeviceModelIPhone8_1]) return @"iPhone8";
else if ([deviceString isEqualToString:kDeviceModelIPhone8P] ||
[deviceString isEqualToString:kDeviceModelIPhone8P_1]) return @"iPhone8 plus";
else if ([deviceString isEqualToString:kDeviceModelIPhoneX] ||
[deviceString isEqualToString:kDeviceModelIPhoneX_1]) return @"iPhoneX";
else if ([deviceString isEqualToString:kDeviceModelIPhoneXSMax] ||
[deviceString isEqualToString:kDeviceModelIPhoneXSMax_1]) return @"iPhone XS Max";
else if ([deviceString isEqualToString:kDeviceModelIPhoneXS]) return @"iPhone XS";
else if ([deviceString isEqualToString:kDeviceModelIPhoneXR] ) return @"iPhone XR";
else if ([deviceString isEqualToString:kDeviceModelIPhone11] ) return @"iPhone11";
else if ([deviceString isEqualToString:kDeviceModelIPhone11_Pro] ) return @"iPhone11 Pro";
else if ([deviceString isEqualToString:kDeviceModelIPhone11_Pro_Max] ) return @"iPhone11 Pro Max";
else return @"iPhone";
} else if ([deviceString hasPrefix:@"iPod"]) {
if ([deviceString isEqualToString:kDeviceModelIPodTouch1G]) return @"iPod touch1";
else if ([deviceString isEqualToString:kDeviceModelIPodTouch2G]) return @"iPod touch2";
else if ([deviceString isEqualToString:kDeviceModelIPodTouch3G]) return @"iPod touch3";
else if ([deviceString isEqualToString:kDeviceModelIPodTouch4G]) return @"iPod touch4";
else if ([deviceString isEqualToString:kDeviceModelIPodTouch5G]) return @"iPod touch5";
else if ([deviceString isEqualToString:kDeviceModelIPodTouch6G]) return @"iPod touch6";
else if ([deviceString isEqualToString:kDeviceModelIPodTouch7G]) return @"iPod touch7";
else return @"iPod";
} else if ([deviceString hasPrefix:@"iPad"]) {
// Classic iPad 9.7 inch
if ([deviceString isEqualToString:kDeviceModelIPad]) return @"iPad1";
else if ([deviceString isEqualToString:kDeviceModelIPad2] ||
[deviceString isEqualToString:kDeviceModelIPad2_1] ||
[deviceString isEqualToString:kDeviceModelIPad2_2] ||
[deviceString isEqualToString:kDeviceModelIPad2_3]) return @"iPad2";
else if ([deviceString isEqualToString:kDeviceModelIPad3] ||
[deviceString isEqualToString:kDeviceModelIPad3_1] ||
[deviceString isEqualToString:kDeviceModelIPad3_2]) return @"iPad3";
else if ([deviceString isEqualToString:kDeviceModelIPad4] ||
[deviceString isEqualToString:kDeviceModelIPad4_1] ||
[deviceString isEqualToString:kDeviceModelIPad4_2]) return @"iPad4";
else if ([deviceString isEqualToString:kDeviceModelIPad5_1] ||
[deviceString isEqualToString:kDeviceModelIPad5_2]) return @"iPad5";
else if ([deviceString isEqualToString:kDeviceModelIPad6_1] ||
[deviceString isEqualToString:kDeviceModelIPad6_2]) return @"iPad6";
else if ([deviceString isEqualToString:kDeviceModelIPad7_1] ||
[deviceString isEqualToString:kDeviceModelIPad7_2]) return @"iPad7";
else if ([deviceString isEqualToString:kDeviceModelIPadAir] ||
[deviceString isEqualToString:kDeviceModelIPadAir_1] ||
[deviceString isEqualToString:kDeviceModelIPadAir_2]) return @"iPad Air";
else if ([deviceString isEqualToString:kDeviceModelIPadAir2] ||
[deviceString isEqualToString:kDeviceModelIPadAir2_1]) return @"iPad Air2";
else if ([deviceString isEqualToString:kDeviceModelIPadAir3] ||
[deviceString isEqualToString:kDeviceModelIPadAir3_1]) return @"iPad Air3";
// iPad Pro
else if ([deviceString isEqualToString:kDeviceModelIPadPro97INCH] ||
[deviceString isEqualToString:kDeviceModelIPadPro97INCH_1] ||
[deviceString isEqualToString:kDeviceModelIPadPro129INCH] ||
[deviceString isEqualToString:kDeviceModelIPadPro129INCH_1] ||
[deviceString isEqualToString:kDeviceModelIPadPro129INCH2] ||
[deviceString isEqualToString:kDeviceModelIPadPro129INCH2_1] ||
[deviceString isEqualToString:kDeviceModelIPadPro105INCH2] ||
[deviceString isEqualToString:kDeviceModelIPadPro105INCH2_1] ||
[deviceString isEqualToString:kDeviceModelIPadPro11INCH] ||
[deviceString isEqualToString:kDeviceModelIPadPro11INCH_1] ||
[deviceString isEqualToString:kDeviceModelIPadPro11INCH_2] ||
[deviceString isEqualToString:kDeviceModelIPadPro11INCH_3] ||
[deviceString isEqualToString:kDeviceModelIPadPro3129INCH] ||
[deviceString isEqualToString:kDeviceModelIPadPro3129INCH_1] ||
[deviceString isEqualToString:kDeviceModelIPadPro3129INCH_2] ||
[deviceString isEqualToString:kDeviceModelIPadPro3129INCH_3]
) return @"iPad Pro";
// iPad Mini
else if ([deviceString isEqualToString:kDeviceModelIPadMini] ||
[deviceString isEqualToString:kDeviceModelIPadMini_1] ||
[deviceString isEqualToString:kDeviceModelIPadMini_2]) return @"iPad Mini";
else if ([deviceString isEqualToString:kDeviceModelIPadMini2] ||
[deviceString isEqualToString:kDeviceModelIPadMini2_1] ||
[deviceString isEqualToString:kDeviceModelIPadMini2_2]) return @"iPad Mini2";
else if ([deviceString isEqualToString:kDeviceModelIPadMini3] ||
[deviceString isEqualToString:kDeviceModelIPadMini3_1] ||
[deviceString isEqualToString:kDeviceModelIPadMini3_2]) return @"iPad Mini3";
else if ([deviceString isEqualToString:kDeviceModelIPadMini4] ||
[deviceString isEqualToString:kDeviceModelIPadMini4_1]) return @"iPad Mini4";
else if ([deviceString isEqualToString:kDeviceModelIPadMini5] ||
[deviceString isEqualToString:kDeviceModelIPadMini5_1]) return @"iPad Mini5";
else return @"iPad";
} else if ([deviceString isEqualToString:@"i386"] || [deviceString isEqualToString:@"x86_64"]) {
return @"iPhone Sim";
}
return @"unknown";
}
详情参见:https://github.com/liunianhuaguoyanxi/ZWDeviceDetector.git