1.獲取設(shè)備信息
UIDevice*device?=?[[UIDevicealloc]init];
NSString*name?=?device.name;//獲取設(shè)備用戶的名稱
NSString*model?=?device.model;//獲取設(shè)備的類別
NSString*localizedModel?=?device.localizedModel;//地方型號?(國際化區(qū)域名稱)
NSString*systemName?=?device.systemName;//獲取當(dāng)前運行的系統(tǒng)
NSString*systemVersion?=?device.systemVersion;//獲取當(dāng)前系統(tǒng)的版本
NSString*UUID?=?device.identifierForVendor.UUIDString;//獲取設(shè)備的UUID唯一標(biāo)示符
NSLog(@"\n?name:%@\n?model:%@\n?localizedModel:%@\n?systemName:%@\n?systemVersion:%@\n",name,model,localizedModel,systemName,systemVersion);
NSLog(@"\n?UUID:%@",UUID);
//設(shè)備朝向
NSLog(@"設(shè)備朝向?-?%ld",?(long)device.orientation);
//?當(dāng)前設(shè)備是否有轉(zhuǎn)向通知
NSLog(@"設(shè)備轉(zhuǎn)向通知?BOOL-?%d",?device.generatesDeviceOrientationNotifications);
//?是否啟動電池監(jiān)控,默認為NO
NSLog(@"電池監(jiān)控啟用狀態(tài)?BOOL-?%d",?device.batteryMonitoringEnabled);
//用戶界面模式
NSLog(@"用戶界面模式?-?%ld",?(long)device.userInterfaceIdiom);
NSDictionary*infoDict =[[NSBundlemainBundle]infoDictionary];
NSString*versionNum?=[infoDictobjectForKey:@"CFBundleVersion"];//當(dāng)前應(yīng)用版本號碼
NSString*appName?=[infoDictobjectForKey:@"CFBundleDisplayName"];//當(dāng)前應(yīng)用名稱
NSString*appCurVersion?=?[infoDictobjectForKey:@"CFBundleShortVersionString"];//當(dāng)前應(yīng)用軟件版本
2.獲取當(dāng)前屏幕分辨率的信息 屏幕長寬
CGRect rect = [[UIScreenmainScreen]bounds];
CGFloat?scale?=?[[UIScreenmainScreen]scale];
CGFloat?width?=?rect.size.width*?scale;
CGFloat?height?=?rect.size.height*?scale;
NSLog(@"分辨率\n?width:%f\n?height:%f",width,height);
floatscreenHeight?=?[UIScreenmainScreen].bounds.size.height;
floatscreenWidth?=?[UIScreenmainScreen].bounds.size.width;
NSLog(@"屏幕\n?width:%f\n?height:%f",screenWidth,screenHeight);
3.設(shè)備震動
/*
需要加入AudioToolbox?framework,
導(dǎo)入頭文件?#import?
在需要震動的地方寫下面的代碼即可
*/
AudioServicesPlaySystemSound?(kSystemSoundID_Vibrate);
4.獲取電池的相關(guān)信息
//獲取電池當(dāng)前的狀態(tài)
NSLog(@"電池當(dāng)前狀態(tài):%@",[selfgetBatteryState]);
//獲取電量的等級,0.00~1.00
NSLog(@"獲取電量等級:%f",[selfgetBatteryLevel]);
//方法
//獲取電池當(dāng)前的狀態(tài),共有4種狀態(tài)
-(NSString*)?getBatteryState?{
UIDevice*device?=?[UIDevicecurrentDevice];
if(device.batteryState==?UIDeviceBatteryStateUnknown)?{
return@"UnKnow未知";
}elseif(device.batteryState==?UIDeviceBatteryStateUnplugged){
return@"Unplugged電源已拔開";
}elseif(device.batteryState==?UIDeviceBatteryStateCharging){
return@"Charging充電";
}elseif(device.batteryState==?UIDeviceBatteryStateFull){
return@"Full充滿";
}
returnnil;
}
//獲取電量的等級,0.00~1.00
-(float)?getBatteryLevel?{
return[UIDevicecurrentDevice].batteryLevel;
}
5.獲取運營商的信息
/*需導(dǎo)入
#import?
#import?
*/
CTTelephonyNetworkInfo*info?=?[[CTTelephonyNetworkInfoalloc]init];
//獲取運行商名稱
CTCarrier*carrier?=?[infosubscriberCellularProvider];
NSString*mCarrier?=?[NSStringstringWithFormat:@"%@",[carriercarrierName]];
//獲取網(wǎng)絡(luò)類型
NSString*mConnectType?=?[[NSStringalloc]initWithFormat:@"%@",info.currentRadioAccessTechnology];
NSLog(@"運行商:%@",mCarrier);
NSLog(@"網(wǎng)絡(luò)類型:%@",mConnectType);
/*網(wǎng)絡(luò)類型
CTRadioAccessTechnologyGPRS?????????//介于2G和3G之間,也叫2.5G?,過度技術(shù)
CTRadioAccessTechnologyEdge?????????//EDGE為GPRS到第三代移動通信的過渡,EDGE俗稱2.75G
CTRadioAccessTechnologyWCDMA
CTRadioAccessTechnologyHSDPA????????????//亦稱為3.5G(3?G)
CTRadioAccessTechnologyHSUPA????????????//3G到4G的過度技術(shù)
CTRadioAccessTechnologyCDMA1x???????//3G
CTRadioAccessTechnologyCDMAEVDORev0????//3G標(biāo)準(zhǔn)
CTRadioAccessTechnologyCDMAEVDORevA
CTRadioAccessTechnologyCDMAEVDORevB
CTRadioAccessTechnologyeHRPD????????//電信使用的一種3G到4G的演進技術(shù),?3.75G
CTRadioAccessTechnologyLTE??????????//接近4G
*/
6.網(wǎng)絡(luò)狀態(tài)監(jiān)聽
/*導(dǎo)入
系統(tǒng)庫SystemConfiguration.framework
第三方Reachability.h
*/
Reachability*reach?=?[ReachabilityreachabilityWithHostName:@"www.baidu.com"];
switch([reachcurrentReachabilityStatus])
{
caseNotReachable://未連接
NSLog(@"網(wǎng)絡(luò)未連接");
break;
caseReachableViaWiFi://通過wifi連接
NSLog(@"wifi");
break;
caseReachableViaWWAN://通過GPRS連接
NSLog(@"CPRS");
break;
default://未知情況
break;
}
本文Demo:http://download.csdn.net/detail/jackjia2015/9435384
轉(zhuǎn)載自:http://blog.csdn.net/jackjia2015/article/details/50685536