ios 中获取设备信息

      -(void)getDeviceNetInfo{
//监听移动服务提供商的变化,如开机状态,更换SIM卡
//设备唯一标识符
NSString *identifierStr = [[[UIDevice currentDevice] identifierForVendor]UUIDString];
NSLog(@"设备唯一标识符--%@",identifierStr);
//手机别名,用户定义的名称
NSString *userPhoneName = [[UIDevice currentDevice]name];
NSLog(@"手机别名--%@",userPhoneName);
//设备名称-
NSString *deviceName = [[UIDevice currentDevice]systemName];
NSLog(@"deviceName--%@",deviceName);
//手机系统版本号
NSString *phoneVersion = [[UIDevice currentDevice]systemVersion];
NSLog(@"手机系统版本号--%@",phoneVersion);
NSString *model = [[UIDevice currentDevice]model];
        //利用该方法只能获取到是iPhone还是ipad不能准确获取到当前设备的具体信息,所以需要使用[self deviceVersion];方法获取到准确的设备信息
NSLog(@"model---%@",model);
//手机型号
NSString *phoeModel = [self deviceVersion];
NSLog(@"phoeModel---%@",phoeModel);

NSLog(@"手机型号--%@",phoeModel);
//地方型号(国际化区域名称)
NSString *localPhoneModel = [[UIDevice currentDevice]localizedModel];
NSLog(@"国际化区域名称--%@",localPhoneModel);
//获取当前应用的版本号
NSDictionary  * infoDictionary = [[NSBundle mainBundle]infoDictionary];
NSString *appCurentVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
NSLog(@"当期应用的版本号--%@",appCurentVersion);

// 当前应用版本号码   int类型
NSString *appCurVersionNum = [infoDictionary objectForKey:@"CFBundleVersion"];
NSLog(@"当前应用版本号--%@",appCurVersionNum);

CTTelephonyNetworkInfo *info = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = info.subscriberCellularProvider;
NSLog(@"运营商:%@", carrier.carrierName);

NSString *netStr =  [self getDeviceModel];
NSLog(@"netStr--%@",netStr);
      }                
        
    -(NSString *)deviceVersion{

CTTelephonyNetworkInfo *info = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = [info subscriberCellularProvider];
//运营商名称
NSString *mCarrier = [NSString stringWithFormat:@"%@",[carrier carrierName]];
//运营商网络类型
NSString *mConnectType = [[NSString alloc] initWithFormat:@"%@",info.currentRadioAccessTechnology];

NSMutableString *allNetInfoString = [NSMutableString string];

if (mCarrier && mCarrier.length) {
    [allNetInfoString appendString:mCarrier];
}

if([AFNetworkReachabilityManager sharedManager].reachableViaWWAN)
{
    //NSLog(@"wwlan");
    
    if ([mConnectType isEqualToString:CTRadioAccessTechnologyGPRS]) {
        [allNetInfoString appendString:@" GRPG"];
        
    }else if ([mConnectType isEqualToString:CTRadioAccessTechnologyEdge]) {
        [allNetInfoString appendString:@" 2G"];
        
    }else if ([mConnectType isEqualToString:CTRadioAccessTechnologyWCDMA] || [mConnectType isEqualToString:CTRadioAccessTechnologyHSDPA] || [mConnectType isEqualToString:CTRadioAccessTechnologyHSUPA] || [mConnectType isEqualToString:CTRadioAccessTechnologyCDMA1x] || [mConnectType isEqualToString:CTRadioAccessTechnologyCDMAEVDORev0] || [mConnectType isEqualToString:CTRadioAccessTechnologyCDMAEVDORevA] || [mConnectType isEqualToString:CTRadioAccessTechnologyCDMAEVDORevB] || [mConnectType isEqualToString:CTRadioAccessTechnologyeHRPD]) {
        [allNetInfoString appendString:@" 3G"];
        
    }else if ([mConnectType isEqualToString:CTRadioAccessTechnologyLTE])
    {
        [allNetInfoString appendString:@" 4G"];
        
    }
    
    
}else if([AFNetworkReachabilityManager sharedManager].reachableViaWiFi)
{
    //NSLog(@"wifi");
    
    [allNetInfoString appendString:@" WiFi"];
    
}

/*   信息参照表
 CTRadioAccessTechnologyGPRS         //介于2G和3G之间,也叫2.5G ,过度技术
 CTRadioAccessTechnologyEdge         //EDGE为GPRS到第三代移动通信的过渡,EDGE俗称2.75G
 CTRadioAccessTechnologyWCDMA
 CTRadioAccessTechnologyHSDPA            //亦称为3.5G(3?G)
 CTRadioAccessTechnologyHSUPA            //3G到4G的过度技术
 CTRadioAccessTechnologyCDMA1x       //3G
 CTRadioAccessTechnologyCDMAEVDORev0    //3G标准
 CTRadioAccessTechnologyCDMAEVDORevA
 CTRadioAccessTechnologyCDMAEVDORevB
 CTRadioAccessTechnologyeHRPD        //电信使用的一种3G到4G的演进技术, 3.75G
 CTRadioAccessTechnologyLTE          //接近4G
 
 */

return allNetInfoString;


                                                                                                                              }                                                                                                                                                  //获取设备型号
                                                                                                                                                          - (NSString *)getDeviceModel
                                                                                                                                          {
struct utsname systemInfo;
uname(&systemInfo);
NSString *deviceString = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
NSLog(@"deviceString--%@",deviceString);
                                                                                                                        NSArray *modelArray = @[
                        
                        @"i386", @"x86_64",
                        
                        @"iPhone1,1",
                        @"iPhone1,2",
                        @"iPhone2,1",
                        @"iPhone3,1",
                        @"iPhone3,2",
                        @"iPhone3,3",
                        @"iPhone4,1",
                        @"iPhone5,1",
                        @"iPhone5,2",
                        @"iPhone5,3",
                        @"iPhone5,4",
                        @"iPhone6,1",
                        @"iPhone6,2",
                        @"iPhone7,2",
                        @"iPhone7,1",
                        @"iPhone8,1",
                        @"iPhone8,2",
                        @"iPhone9,1",
                        @"iPhone9,2",
                        
                        @"iPod1,1",
                        @"iPod2,1",
                        @"iPod3,1",
                        @"iPod4,1",
                        @"iPod5,1",
                        
                        @"iPad1,1",
                        @"iPad2,1",
                        @"iPad2,2",
                        @"iPad2,3",
                        @"iPad2,4",
                        @"iPad3,1",
                        @"iPad3,2",
                        @"iPad3,3",
                        @"iPad3,4",
                        @"iPad3,5",
                        @"iPad3,6",
                        
                        @"iPad2,5",
                        @"iPad2,6",
                        @"iPad2,7",
                        ];
NSArray *modelNameArray = @[
                            
                            @"iPhone Simulator",
                            @"iPhone Simulator",
                            @"iPhone 2G",
                            @"iPhone 3G",
                            @"iPhone 3GS",
                            @"iPhone 4(GSM)",
                            @"iPhone 4(GSM Rev A)",
                            @"iPhone 4(CDMA)",
                            @"iPhone 4S",
                            @"iPhone 5(GSM)",
                            @"iPhone 5(GSM+CDMA)",
                            @"iPhone 5c(GSM)",
                            @"iPhone 5c(Global)",
                            @"iphone 5s(GSM)",
                            @"iphone 5s(Global)",
                            @"iPhone 6",
                            @"iPhone 6 Plus",
                            @"iPhone 6s",
                            @"iPhone 6s Plus",
                            @"iPhone 7",
                            @"iPhone 7 Plus",
                            
                            @"iPod Touch 1G",
                            @"iPod Touch 2G",
                            @"iPod Touch 3G",
                            @"iPod Touch 4G",
                            @"iPod Touch 5G",
                            
                            @"iPad",
                            @"iPad 2(WiFi)",
                            @"iPad 2(GSM)",
                            @"iPad 2(CDMA)",
                            @"iPad 2(WiFi + New Chip)",
                            @"iPad 3(WiFi)",
                            @"iPad 3(GSM+CDMA)",
                            @"iPad 3(GSM)",
                            @"iPad 4(WiFi)",
                            @"iPad 4(GSM)",
                            @"iPad 4(GSM+CDMA)",
                            
                            @"iPad mini (WiFi)",
                            @"iPad mini (GSM)",
                            @"ipad mini (GSM+CDMA)",
                            
                            @"iPad mini2 (WiFi)",
                            @"iPad mini2 (GSM)",
                            @"ipad mini2 (GSM+CDMA)",
                            
                            @"iPad mini3 (WiFi)",
                            @"iPad mini3 (GSM)",
                            @"ipad mini3 (GSM+CDMA)"
                            
                            ];
        NSInteger modelIndex = - 1;
        NSString *modelNameString = nil;
        modelIndex = [modelArray indexOfObject:deviceString];
      if (modelIndex >= 0 && modelIndex < [modelNameArray count])         {
    modelNameString = [modelNameArray             objectAtIndex:modelIndex];
                  }
                        return modelNameString;
                                                                                                                            }

推荐阅读更多精彩内容