iphone 获取硬件型号

这个写原创不知道会不会被人打,要想获取手机硬件的型号

+ (NSString *)platform
{
    size_t size;
    sysctlbyname("hw.machine", NULL, &size, NULL, 0);
    char *machine = malloc(size);
    sysctlbyname("hw.machine", machine, &size, NULL, 0);
    NSString *platform = [NSString stringWithCString:machine encoding:NSUTF8StringEncoding];
    free(machine);
    return platform;
}

+ (NSString *) getPlatform
{
    NSString *platform = [self platform];
    if ([platform isEqualToString:@"iPhone1,1"])    return @"iPhone 1G";
    if ([platform isEqualToString:@"iPhone1,2"])    return @"iPhone 3G";
    if ([platform isEqualToString:@"iPhone2,1"])    return @"iPhone 3GS";
    if ([platform isEqualToString:@"iPhone3,1"])    return @"iPhone 4 (GSM)";
    if ([platform isEqualToString:@"iPhone3,3"])    return @"iPhone 4 (CDMA/Verizon/Sprint)";
    if ([platform isEqualToString:@"iPhone4,1"])    return @"iPhone 4s";
    if ([platform isEqualToString:@"iPhone5,1"])    return @"iPhone 5 GSM";
    if ([platform isEqualToString:@"iPhone5,2"])    return @"iPhone 5 CDMA";
    if ([platform isEqualToString:@"iPhone5,3"])    return @"iPhone 5c";
    if ([platform isEqualToString:@"iPhone6,1"])    return @"iPhone 5s";
    if ([platform isEqualToString:@"iPhone7,1"])    return @"iPhone 6 Plus";
    if ([platform isEqualToString:@"iPhone7,2"])    return @"iPhone 6";

    if ([platform isEqualToString:@"iPod1,1"])      return @"iPod Touch 1G";
    if ([platform isEqualToString:@"iPod2,1"])      return @"iPod Touch 2G";
    if ([platform isEqualToString:@"iPod3,1"])      return @"iPod Touch 3G";
    if ([platform isEqualToString:@"iPod4,1"])      return @"iPod Touch 4G";

    if ([platform isEqualToString:@"iPad1,1"])      return @"iPad";
    if ([platform isEqualToString:@"iPad2,1"])      return @"iPad 2 (Wi-Fi Only)";
    if ([platform isEqualToString:@"iPad2,2"])      return @"iPad 2 (Wi-Fi/GSM/GPS)";
    if ([platform isEqualToString:@"iPad2,3"])      return @"iPad 2 (Wi-Fi/CDMA/GPS)";
    if ([platform isEqualToString:@"iPad2,4"])      return @"iPad 2 (Wi-Fi Only, iPad2,4)";
    if ([platform isEqualToString:@"iPad2,5"])      return @"iPad mini (Wi-Fi Only)";
    if ([platform isEqualToString:@"iPad2,6"])      return @"iPad mini (Wi-Fi/AT&T/GPS)";
    if ([platform isEqualToString:@"iPad2,7"])      return @"iPad mini (Wi-Fi/Verizon & Sprint/GPS)";

    if ([platform isEqualToString:@"iPad3,1"])      return @"iPad 3rd Gen (Wi-Fi Only)";
    if ([platform isEqualToString:@"iPad3,2"])      return @"iPad 3rd Gen (Wi-Fi/Cellular Verizon/GPS)";
    if ([platform isEqualToString:@"iPad3,3"])      return @"iPad 3rd Gen (Wi-Fi/Cellular AT&T/GPS)";
    if ([platform isEqualToString:@"iPad3,4"])      return @"iPad 4th Gen (Wi-Fi Only)";

    if ([platform isEqualToString:@"iPad3,1"])      return @"iPad 3rd Gen (Wi-Fi Only)";

    if ([platform isEqualToString:@"i386"] || [platform isEqualToString:@"x86_64"])         return @"iPhone Simulator";

    return platform;
}

用这个就OK了,当然你要是要完整一点的对应

Apple Device                              | Model Identifier
--------------------------------------------------------------
iPad Wi-Fi (Original)                     | iPad1,1
iPad Wi-Fi/3G/GPS (Original)              | iPad1,1
iPad 2 (Wi-Fi Only)                       | iPad2,1
iPad 2 (Wi-Fi/GSM/GPS)                    | iPad2,2
iPad 2 (Wi-Fi/CDMA/GPS)                   | iPad2,3
iPad 2 (Wi-Fi Only, iPad2,4)              | iPad2,4
iPad 3rd Gen (Wi-Fi Only)                 | iPad3,1
iPad 3rd Gen (Wi-Fi/Cellular AT&T/GPS)    | iPad3,3
iPad 3rd Gen (Wi-Fi/Cellular Verizon/GPS) | iPad3,2
iPad 4th Gen (Wi-Fi Only)                 | iPad3,4
iPad 4th Gen (Wi-Fi/AT&T/GPS)             | Pending
iPad 4th Gen (Wi-Fi/Verizon & Sprint/GPS) | Pending
iPad mini (Wi-Fi Only)                    | iPad2,5
iPad mini (Wi-Fi/AT&T/GPS)                | iPad2,6
iPad mini (Wi-Fi/Verizon & Sprint/GPS)    | iPad2,7
iPhone (Original/EDGE)                    | iPhone1,1
iPhone 3G iPhone1,2 1 iPhone 3GS          | iPhone2,1
iPhone 3G (China/No Wi-Fi)                | iPhone1,2*
iPhone 3GS (China/No Wi-Fi)               | iPhone2,1*
iPhone 4 (GSM)                            | iPhone3,1
iPhone 4 (CDMA/Verizon/Sprint)            | iPhone3,3
iPhone 4S                                 | iPhone4,1
iPhone 5 (GSM/LTE 4, 17/North America)    | iPhone5,1
iPhone 5 (CDMA/LTE, Sprint/Verizon/KDDI)  | iPhone5,2
iPhone 5 (GSM/LTE 1, 3, 5/International)  | iPhone5,1
iPhone 5S                                 | iPhone6,1
iPod (Original/Scroll Wheel)              | None
iPod 2nd Gen (Touch Wheel)                | None
iPod 3rd Gen (10/15/30)                   | None
iPod 3rd Gen (10/20/40)                   | None
iPod 3rd Gen (15/20/40)                   | None
iPod 4th Gen (ClickWheel)                 | None
iPod U2 Edition (4th Gen)                 | None
iPod photo (30)                           | None
iPod photo (40/60)                        | None
iPod Color Display                        | None
iPod U2 Edition (Color)                   | None
iPod 5th Gen (with Video)                 | None
iPod U2 Edition 5th Gen                   | None
iPod 5th Gen - Enhanced                   | None
iPod U2 Edition 5th Gen Enhanced          | None
iPod classic ("Original"/6th Gen)         | None
iPod classic (Late 2008/7th Gen)          | None
iPod mini                                 | None
iPod mini (2nd Gen)                       | None
iPod nano                                 | None
iPod nano (2nd Gen)                       | None
iPod nano 2nd Gen (RED)                   | None
iPod nano (3rd Gen/Fat)                   | None
iPod nano (4th Gen)                       | None
iPod nano (5th Gen/Camera)                | None
iPod nano (6th Gen/1.54" Multitouch/Clip) | None
iPod nano (7th Gen/2.5" Multitouch)       | None
iPod shuffle (White)                      | None
iPod shuffle 2nd Gen (Silver)             | None
iPod shuffle 2nd Gen (Colors/Early 2007)  | None
iPod shuffle 2nd Gen (Late 2007)          | None
iPod shuffle 2nd Gen (Late 2008)          | None
iPod shuffle 3rd Gen                      | None
iPod shuffle 3rd Gen (Colors)             | None
iPod shuffle 4th Gen (Wheel/VoiceOver)    | None
iPod shuffle 4th Gen (2012)               | None
iPod touch (Original)                     | iPod1,1
iPod touch (2nd Gen)                      | iPod2,1
iPod touch (3rd Gen/8 GB)                 | iPod3,1
iPod touch (3rd Gen/32 & 64 GB)           | iPod3,1
iPod touch (4th Gen/FaceTime)             | iPod4,1
iPod touch (4th Gen, 2011)                | iPod4,1
iPod touch (4th Gen, 2012)                | iPod4,1
iPod touch (5th Gen)                      | iPod5,1 
时间: 2024-10-12 21:45:00

iphone 获取硬件型号的相关文章

Atitit.获取主板与bios序列号获取硬件设备信息  Wmi wmic 的作用

Atitit.获取主板与bios序列号获取硬件设备信息  Wmi wmic 的作用 1 获取硬件核心基础核心基础Wmi1 2 其他资料2 3 Wmic WMI 命令行接口2 4 Atitit.获取主板与bios序列号2 5 参考3 1 获取硬件核心基础核心基础Wmi WMI,是Windows 2K/XP管理系统的核心:对于其他的Win32操作系统,WMI是一个有用的插件.WMI以CIMOM为基础,CIMOM即公共信息模型对象管理器(Common Information Model Object 

python执行shell获取硬件参数写入mysql

最近要获取服务器各种参数,包括cpu.内存.磁盘.型号等信息.试用了Hyperic HQ.Nagios和Snmp,它们功能都挺强大的,但是于需求不是太符,亦或者太heavy. 于是乎想到用python执行shell获取这些信息,python执行shell脚本有以下三种方法: 1. os.system() os.system('ls')#返回结果0或者1,不能得到命令的输出 2. os.popen() output = os.popen('ls') print output.read()#打印出的

iOS获取设备型号、装置类型等信息

iOS获取设备型号.设备类型等信息 设备标识 关于设备标识,历史上盛行过很多英雄,比如UDID.Mac地址.OpenUDID等,然而他们都陆陆续续倒在了苹果的门下.苹果目前提供了2个方法供App获取设备标识:idfa和idfv idfa:全称advertisingIdentifier,官方解释是广告标识,适用于广告推广,这个建议不要轻易使用,如果用了,则App里必须提供广告功能,否则很有可能会在AppStore审核时被拒.而且idfa是可以被用户关闭的(设置->隐私),一旦被关闭,就获取不到了.

史上最简单,js并获取手机型号

原先获取不了苹果系列的型号,但转换思路,先推断是否是苹果,再用分辨率获取型号 //获取手机型号函数begin function getPhoneType(){ //正则,忽略大写和小写 var pattern_phone = new RegExp("iphone","i"); var pattern_android = new RegExp("android","i"); var userAgent = navigator.u

获取设备型号

代码: - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. NSLog(@"--self-machine-%@",[self machineName]); } - (NSString*) machineName{ struct utsname systemInfo; uname(&systemInfo); NSString *result =

php获取设备型号

/* 获取设备型号 */ function get_device_type(){ $agent = strtolower($_SERVER['HTTP_USER_AGENT']); $type = 'other'; if(strpos($agent, 'iphone') || strpos($agent, 'ipad') ){ $type = 'ios'; } if(strpos($agent, 'android')){ $type = 'android'; } return $type; }

android 获取手机型号,本机电话号码,SDK版本以及firmwarw版本号(即系统版本号)

Android开发平台中,可通过TelephonyManager 获取本机号码. 1 TelephonyManager phoneMgr=(TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE); 2 txtPhoneNumber.setText(phoneMgr.getLine1Number()); //txtPhoneNumber是一个EditText 用于显示手机号 注: 根据Android的安全机制,在使用Tel

Android编程获取手机型号,本机电话号码,sdk版本及firmware版本号(即系统版本号)

Android开发平台中,可通过TelephonyManager 获取本机号码. TelephonyManager phoneMgr=(TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE); txtPhoneNumber.setText(phoneMgr.getLine1Number()); //txtPhoneNumber是一个EditText 用于显示手机号 注: 根据Android的安全机制,在使用Telepho

iphone获取当前流量信息

通过读取系统网络接口信息,获取当前iphone设备的流量相关信息,统计的是上次开机至今的流量信息. ?1. [代码][C/C++]代码    -(void)checkNetworkflow{    struct ifaddrs *ifa_list = 0, *ifa;    if (getifaddrs(&ifa_list) == -1)    {        return;    }        uint32_t iBytes     = 0;    uint32_t oBytes