iOS设备型号判断,包含iPhone XS等新设备
+ (NSString*)yh_getDeviceName {
// 需要#import "sys/utsname.h"
structutsnamesystemInfo;
uname(&systemInfo);
NSString *deviceString = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
if([deviceStringisEqualToString:@"iPhone3,1"]) return@"iPhone 4";
if([deviceStringisEqualToString:@"iPhone3,2"]) return@"iPhone 4";
if([deviceStringisEqualToString:@"iPhone3,3"]) return@"iPhone 4";
if([deviceStringisEqualToString:@"iPhone4,1"]) return@"iPhone 4S";
if([deviceStringisEqualToString:@"iPhone5,1"]) return@"iPhone 5";
if ([deviceString isEqualToString:@"iPhone5,2"]) return @"iPhone 5 (GSM+CDMA)";
if ([deviceString isEqualToString:@"iPhone5,3"]) return @"iPhone 5c (GSM)";
if ([deviceString isEqualToString:@"iPhone5,4"]) return @"iPhone 5c (GSM+CDMA)";
if ([deviceString isEqualToString:@"iPhone6,1"]) return @"iPhone 5s (GSM)";
if ([deviceString isEqualToString:@"iPhone6,2"]) return @"iPhone 5s (GSM+CDMA)";
if([deviceStringisEqualToString:@"iPhone7,1"]) return@"iPhone 6 Plus";
if([deviceStringisEqualToString:@"iPhone7,2"]) return@"iPhone 6";
if([deviceStringisEqualToString:@"iPhone8,1"]) return@"iPhone 6s";
if ([deviceString isEqualToString:@"iPhone8,2"]) return @"iPhone 6s Plus";
if([deviceStringisEqualToString:@"iPhone8,4"]) return@"iPhone SE";
if([deviceStringisEqualToString:@"iPhone9,1"]) return@"iPhone 7";
if([deviceStringisEqualToString:@"iPhone9,2"]) return@"iPhone 7 Plus";
if([deviceStringisEqualToString:@"iPhone10,1"] || [deviceStringisEqualToString:@"iPhone10,4"]) return@"iPhone 8";
if([deviceStringisEqualToString:@"iPhone10,2"] || [deviceStringisEqualToString:@"iPhone10,5"]) return@"iPhone 8 Plus";
if([deviceStringisEqualToString:@"iPhone10,3"] || [deviceStringisEqualToString:@"iPhone10,6"]) return@"iPhone X";
if([deviceStringisEqualToString:@"iPhone11,2"]) return@"iPhone XS";
if([deviceStringisEqualToString:@"iPhone11,4"] || [deviceStringisEqualToString:@"iPhone11,6"]) return@"iPhone XS Max";
if([deviceStringisEqualToString:@"iPhone11,8"]) return@"iPhone XR";
//--------------------ipod-----------------------
if([deviceStringisEqualToString:@"iPod1,1"]) return@"iPod touch";
if([deviceStringisEqualToString:@"iPod2,1"]) return@"iPod touch 2G";
if([deviceStringisEqualToString:@"iPod3,1"]) return@"iPod touch 3G";
if([deviceStringisEqualToString:@"iPod4,1"]) return@"iPod touch 4G";
if([deviceStringisEqualToString:@"iPod5,1"]) return@"iPod touch 5G";
if([deviceStringisEqualToString:@"iPod7,1"]) return@"iPod touch 6G";
//--------------------ipad-------------------------
if([deviceStringisEqualToString:@"iPad1,1"]) return@"iPad";
if([deviceStringisEqualToString:@"iPad1,2"]) return@"iPad 3G";
if([deviceStringisEqualToString:@"iPad2,1"] || [deviceStringisEqualToString:@"iPad2,2"] || [deviceStringisEqualToString:@"iPad2,3"] || [deviceStringisEqualToString:@"iPad2,4"]) return@"iPad 2";
if([deviceStringisEqualToString:@"iPad3,1"] || [deviceStringisEqualToString:@"iPad3,2"] || [deviceStringisEqualToString:@"iPad3,3"]) return@"iPad 3";
if([deviceStringisEqualToString:@"iPad3,4"] || [deviceStringisEqualToString:@"iPad3,5"] || [deviceStringisEqualToString:@"iPad3,6"]) return@"iPad 4";
if([deviceStringisEqualToString:@"iPad4,1"] || [deviceStringisEqualToString:@"iPad4,2"] || [deviceStringisEqualToString:@"iPad4,3"]) return@"iPad Air";
if([deviceStringisEqualToString:@"iPad5,3"] || [deviceStringisEqualToString:@"iPad5,4"]) return@"iPad Air 2";
if([deviceStringisEqualToString:@"iPad6,7"] || [deviceStringisEqualToString:@"iPad6,8"]) return@"iPad Pro 12.9-inch";
if([deviceStringisEqualToString:@"iPad6,3"] || [deviceStringisEqualToString:@"iPad6,4"]) return@"iPad Pro iPad 9.7-inch";
if([deviceStringisEqualToString:@"iPad6,11"] || [deviceStringisEqualToString:@"iPad6,12"]) return@"iPad 5";
if([deviceStringisEqualToString:@"iPad7,1"] || [deviceStringisEqualToString:@"iPad7,2"]) return@"iPad Pro 12.9-inch 2";
if([deviceStringisEqualToString:@"iPad7,3"] || [deviceStringisEqualToString:@"iPad7,4"]) return@"iPad Pro 10.5-inch";
//----------------iPad mini------------------------
if([deviceStringisEqualToString:@"iPad2,5"] || [deviceStringisEqualToString:@"iPad2,6"] || [deviceStringisEqualToString:@"iPad2,7"]) return@"iPad mini";
if([deviceStringisEqualToString:@"iPad4,4"] || [deviceStringisEqualToString:@"iPad4,5"] || [deviceStringisEqualToString:@"iPad4,6"]) return@"iPad mini 2";
if([deviceStringisEqualToString:@"iPad4,7"] || [deviceStringisEqualToString:@"iPad4,8"] || [deviceStringisEqualToString:@"iPad4,9"]) return@"iPad mini 3";
if([deviceStringisEqualToString:@"iPad5,1"] || [deviceStringisEqualToString:@"iPad5,2"]) return@"iPad mini 4";
if([deviceStringisEqualToString:@"iPad4,1"]) return@"ipad air";
if([deviceStringisEqualToString:@"i386"]) return@"Simulator";
if([deviceStringisEqualToString:@"x86_64"]) return@"Simulator";
returndeviceString;
}