获取设备和 App 信息
设备对照表:https://www.theiphonewiki.com/wiki/Models
获取设备和 App 信息代码:
NSLog(@"设备信息如下");
NSLog(@"detailModel(详细型号): %@", [self detailModel]); //detailModel(详细型号): iPhone 6 UIDevice *device = [UIDevice currentDevice];
NSLog(@"name(名称): %@", [device name]); //name(名称): My iPhone
NSLog(@"model(型号): %@", [device model]); //model(型号): iPhone
NSLog(@"localizedModel(本地化型号): %@", [device localizedModel]); //localizedModel(本地化型号): iPhone
NSLog(@"systemName(系统名称): %@", [device systemName]); //systemName(系统名称): iPhone OS
NSLog(@"systemVersion(系统版本): %@", [device systemVersion]); //systemVersion(系统版本): 8.3
NSLog(@"identifierForVendor(UUID): %@", [device identifierForVendor]); //identifierForVendor(UUID): <__NSConcreteUUID 0x7ff21b5c8410> 1F61341F-26B2-419C-8B35-75E8F1097CBD NSLog(@"App信息如下");
NSDictionary *dicAppInfo = [[NSBundle mainBundle] infoDictionary];
NSString *shortVersion = [dicAppInfo objectForKey:@"CFBundleShortVersionString"];
NSString *buildVersion = [dicAppInfo objectForKey:@"CFBundleVersion"];
NSString *name = [dicAppInfo objectForKey:@"CFBundleName"];
NSString *displayName = [dicAppInfo objectForKey:@"CFBundleDisplayName"];
NSString *identifier = [dicAppInfo objectForKey:@"CFBundleIdentifier"];
NSString *minimumOSVersion = [dicAppInfo objectForKey:@"MinimumOSVersion"]; NSLog(@"CFBundleShortVersionString(Version版本): %@", shortVersion); //CFBundleShortVersionString(Version版本): 1.0
NSLog(@"CFBundleVersion(Build版本): %@", buildVersion); //CFBundleVersion(Build版本): 1
NSLog(@"CFBundleName(名称): %@", name); //CFBundleName(名称): FirstBook187
NSLog(@"CFBundleDisplayName(显示名称): %@", displayName); //CFBundleDisplayName(显示名称): (null);默认为null,因为Info.plist文件默认不会添加“Bundle display name”,而App的显示名称优先级来说:CFBundleDisplayName>CFBundleName,即CFBundleDisplayName不存在的情况下,就是显示CFBundleName
NSLog(@"CFBundleIdentifier(标识符): %@", identifier); //CFBundleIdentifier(标识符): com.kenmu.FirstBook187
NSLog(@"MinimumOSVersion(兼容的最小操作系统版本): %@", minimumOSVersion); //MinimumOSVersion(兼容的最小操作系统版本): 7.0 CFShow((__bridge CFTypeRef)(dicAppInfo)); //通过CFShow可以输出dicAppInfo的所有键值对信息;真机输出的信息比模拟器多
获取设备详细型号的代码:
#import "sys/utsname.h"
- (NSString *)detailModel {
//{代号 : 详细型号}
NSDictionary *dicDeviceInfo = @{ @"x86_64" : @"Simulator",
@"i386" : @"Simulator",
@"iPhone7,2" : @"iPhone 6",
@"iPhone7,1" : @"iPhone 6 Plus",
@"iPhone6,2" : @"iPhone 5s (Global)",
@"iPhone6,1" : @"iPhone 5s (GSM)",
@"iPhone5,4" : @"iPhone 5c (Global)",
@"iPhone5,3" : @"iPhone 5c (GSM)",
@"iPhone5,2" : @"iPhone 5 (GSM+CDMA)",
@"iPhone5,1" : @"iPhone 5 (GSM)",
@"iPhone4,1" : @"iPhone 4S",
@"iPhone3,3" : @"iPhone 4 (CDMA)",
@"iPhone3,2" : @"iPhone 4 (GSM Rev A)",
@"iPhone3,1" : @"iPhone 4 (GSM)",
@"iPhone2,1" : @"iPhone 3GS",
@"iPhone1,2" : @"iPhone 3G",
@"iPhone1,1" : @"iPhone 2G",
@"iPad5,4" : @"iPad Air 2",
@"iPad5,3" : @"iPad Air 2",
@"iPad4,3" : @"iPad Air",
@"iPad4,2" : @"iPad Air",
@"iPad3,6" : @"iPad 4 (GSM+CDMA)",
@"iPad3,5" : @"iPad 4 (GSM)",
@"iPad3,4" : @"iPad 4 (WiFi)",
@"iPad3,3" : @"iPad 3 (GSM)",
@"iPad3,2" : @"iPad 3 (GSM+CDMA)",
@"iPad3,1" : @"iPad 3 (WiFi)",
@"iPad2,4" : @"iPad 2 (WiFi + New Chip)",
@"iPad2,3" : @"iPad 2 (CDMA)",
@"iPad2,2" : @"iPad 2 (GSM)",
@"iPad2,1" : @"iPad 2 (WiFi)",
@"iPad1,1" : @"iPad",
@"iPad4,9" : @"iPad mini 3",
@"iPad4,8" : @"iPad mini 3",
@"iPad4,7" : @"iPad mini 3",
@"iPad4,6" : @"iPad mini 2",
@"iPad4,5" : @"iPad mini 2",
@"iPad4,4" : @"iPad mini 2",
@"iPad2,7" : @"iPad mini 1G (WiFi)",
@"iPad2,6" : @"iPad mini 1G (GSM)",
@"iPad2,5" : @"iPad mini 1G (GSM+CDMA)",
@"iPod5,1" : @"iPod touch 5G",
@"iPod4,1" : @"iPod touch 4G",
@"iPod3,1" : @"iPod touch 3G",
@"iPod2,1" : @"iPod touch 2G",
@"iPod1,1" : @"iPod touch",
@"Watch1,2" : @"Apple Watch",
@"Watch1,1" : @"Apple Watch",
@"AppleTV3,2" : @"Apple TV 3G",
@"AppleTV3,1" : @"Apple TV 3G",
@"AppleTV2,1" : @"Apple TV 2G" };
struct utsname systemInfo; //这是LINUX系统放硬件版本的信息的地方;所以需要导入包sys/utsname.h
uname(&systemInfo);
NSString *strMachineCode = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
//也可以用allKeys和indexOfObject结合,来判断是否此设备代号存在,再获取它对应的详细型号
NSString *strDetailModel = [dicDeviceInfo objectForKey:strMachineCode];
if(!strDetailModel) {
strDetailModel = @"Unknown Device";
}
return strDetailModel;
}
结果:
-- ::10.315 FirstBook187[:] 设备信息如下
-- ::10.316 FirstBook187[:] detailModel(详细型号): Simulator
-- ::10.316 FirstBook187[:] name(名称): iPhone Simulator
-- ::10.316 FirstBook187[:] model(型号): iPhone Simulator
-- ::10.316 FirstBook187[:] localizedModel(本地化型号): iPhone Simulator
-- ::10.317 FirstBook187[:] systemName(系统名称): iPhone OS
-- ::10.317 FirstBook187[:] systemVersion(系统版本): 8.3
-- ::10.317 FirstBook187[:] identifierForVendor(UUID): <__NSConcreteUUID 0x7fbc5365b290> 1F61341F-26B2-419C-8B35-75E8F1097CBD
-- ::10.318 FirstBook187[:] App信息如下
-- ::10.318 FirstBook187[:] CFBundleShortVersionString(Version版本): 1.0
-- ::10.318 FirstBook187[:] CFBundleVersion(Build版本):
-- ::10.318 FirstBook187[:] CFBundleName(名称): FirstBook187
-- ::10.318 FirstBook187[:] CFBundleDisplayName(显示名称): (null)
-- ::10.376 FirstBook187[:] CFBundleIdentifier(标识符): com.kenmu.FirstBook187
-- ::10.376 FirstBook187[:] MinimumOSVersion(兼容的最小操作系统版本): 7.0
<CFBasicHash 0x7fbc53504d60 [0x101ad8180]>{type = mutable dict, count = ,
entries =>
: <CFString 0x7fbc535048d0 [0x101ad8180]>{contents = "CFBundleName"} = <CFString 0x7fbc53504d40 [0x101ad8180]>{contents = "FirstBook187"}
: <CFString 0x7fbc535030c0 [0x101ad8180]>{contents = "DTSDKName"} = <CFString 0x7fbc53504c90 [0x101ad8180]>{contents = "iphonesimulator8.3"}
: <CFString 0x101ab0b40 [0x101ad8180]>{contents = "CFBundleInfoPlistURL"} = <CFURL 0x7fbc53503e70 [0x101ad8180]>{string = Info.plist, encoding =
base = <CFURL 0x7fbc53503610 [0x101ad8180]>{string = file:///Users/Kenmu/Library/Developer/CoreSimulator/Devices/85240D3B-7BE5-4AF1-A570-F2116C2B7979/data/Containers/Bundle/Application/7FCB8335-0BD8-4A70-B0CC-17D8512FA327/FirstBook187.app/, encoding = 134217984, base = (null)}}
: <CFString 0x101ab0b80 [0x101ad8180]>{contents = "CFBundleNumericVersion"} = <CFNumber 0xb000000010080002 [0x101ad8180]>{value = +, type = kCFNumberSInt32Type}
: <CFString 0x7fbc535046c0 [0x101ad8180]>{contents = "UILaunchStoryboardName"} = <CFString 0x7fbc53504a00 [0x101ad8180]>{contents = "LaunchScreen"}
: <CFString 0x7fbc53504880 [0x101ad8180]>{contents = "CFBundleDevelopmentRegion"} = <CFString 0x7fbc53504cc0 [0x101ad8180]>{contents = "en"}
: <CFString 0x7fbc53503e00 [0x101ad8180]>{contents = "CFBundleVersion"} = <CFString 0x7fbc535049e0 [0x101ad8180]>{contents = ""}
: <CFString 0x7fbc53503e40 [0x101ad8180]>{contents = "DTPlatformName"} = <CFString 0x7fbc53504c60 [0x101ad8180]>{contents = "iphonesimulator"}
: <CFString 0x7fbc53504850 [0x101ad8180]>{contents = "CFBundlePackageType"} = <CFString 0x7fbc53504c40 [0x101ad8180]>{contents = "APPL"}
: <CFString 0x7fbc53503dd0 [0x101ad8180]>{contents = "UIMainStoryboardFile"} = <CFString 0x7fbc535049c0 [0x101ad8180]>{contents = "Main"}
: <CFString 0x7fbc535047f0 [0x101ad8180]>{contents = "CFBundleSupportedPlatforms"} = <CFArray 0x7fbc53504bc0 [0x101ad8180]>{type = mutable-small, count = , values = (
: <CFString 0x7fbc53504b90 [0x101ad8180]>{contents = "iPhoneSimulator"}
)}
: <CFString 0x7fbc53504750 [0x101ad8180]>{contents = "CFBundleShortVersionString"} = <CFString 0x7fbc53504a40 [0x101ad8180]>{contents = "1.0"}
: <CFString 0x7fbc53503da0 [0x101ad8180]>{contents = "CFBundleInfoDictionaryVersion"} = <CFString 0x7fbc535049a0 [0x101ad8180]>{contents = "6.0"}
: <CFString 0x7fbc53503bb0 [0x101ad8180]>{contents = "UIRequiredDeviceCapabilities"} = <CFArray 0x7fbc53504910 [0x101ad8180]>{type = mutable-small, count = , values = (
: <CFString 0x7fbc535048f0 [0x101ad8180]>{contents = "armv7"}
)}
: <CFString 0x7fbc535046f0 [0x101ad8180]>{contents = "CFBundleExecutable"} = <CFString 0x7fbc53504a20 [0x101ad8180]>{contents = "FirstBook187"}
: <CFString 0x7fbc535047c0 [0x101ad8180]>{contents = "MinimumOSVersion"} = <CFString 0x7fbc53504b70 [0x101ad8180]>{contents = "7.0"}
: <CFString 0x7fbc53503d70 [0x101ad8180]>{contents = "CFBundleIdentifier"} = <CFString 0x7fbc53504970 [0x101ad8180]>{contents = "com.kenmu.FirstBook187"}
: <CFString 0x7fbc535048b0 [0x101ad8180]>{contents = "UIDeviceFamily"} = <CFArray 0x7fbc53504ce0 [0x101ad8180]>{type = mutable-small, count = , values = (
: <CFNumber 0xb000000000000013 [0x101ad8180]>{value = +, type = kCFNumberSInt64Type}
)}
: <CFString 0x7fbc53504820 [0x101ad8180]>{contents = "CFBundleSignature"} = <CFString 0x7fbc53504c20 [0x101ad8180]>{contents = "????"}
: <CFString 0x7fbc53504720 [0x101ad8180]>{contents = "LSRequiresIPhoneOS"} = <CFBoolean 0x101ad8bf0 [0x101ad8180]>{value = true}
: <CFString 0x7fbc53504780 [0x101ad8180]>{contents = "UISupportedInterfaceOrientations"} = <CFArray 0x7fbc53504b10 [0x101ad8180]>{type = mutable-small, count = , values = (
: <CFString 0x7fbc53504a60 [0x101ad8180]>{contents = "UIInterfaceOrientationPortrait"}
: <CFString 0x7fbc53504a90 [0x101ad8180]>{contents = "UIInterfaceOrientationLandscapeLeft"}
: <CFString 0x7fbc53504ad0 [0x101ad8180]>{contents = "UIInterfaceOrientationLandscapeRight"}
)}
}
获取设备和 App 信息的更多相关文章
- 获取设备、APP的一些信息
获取设备的一些信息: UIDevice *device = [UIDevice currentDevice]; @property(nonatomic,readonly,strong) NSStrin ...
- Cordova各个插件使用介绍系列(六)—$cordovaDevice获取设备的相关信息
详情请看:Cordova各个插件使用介绍系列(六)—$cordovaDevice获取设备的相关信息 在项目中需要获取到当前设备,例如手机的ID,联网状态,等,然后这个Cordova里有这个插件可以用, ...
- ios 获取设备相关的信息
.获取设备的信息 UIDevice *device = [[UIDevice alloc] int]; NSString *name = device.name; //获取设备所有者的名称 NSStr ...
- iOS ---------- 获取设备的各种信息
一.目录结构: 获取屏幕宽度与高度 获取设备版本号 获取iPhone名称 获取app版本号 获取电池电量 获取当前系统名称 获取当前系统版本号 获取通用的唯一识别码UUID 获取当前设备IP 获取总内 ...
- iOS 获取设备的各种信息的方法
一.目录结构: 获取屏幕宽度与高度 获取设备版本号 获取iPhone名称 获取app版本号 获取电池电量 获取当前系统名称 获取当前系统版本号 获取通用的唯一识别码UUID 获取当前设备IP 获取总内 ...
- Android开发之获取设备的屏幕信息和px dp之间的转换
DisplayMetrics metric = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metr ...
- snmp获取设备相关管理信息
在本文中,作者将向我们展示如何用snmp代理监视网络设备,甚至发送软件警告. 网络上很多代理在为我们服务.只要我们开启UDP/161,162端口,这些代理就会以Management Informati ...
- C#:获取设备电量相关信息
更多资源:http://denghejun.github.io [DllImport("kernel32.dll",EntryPoint="GetSystemPowerS ...
- iOS 随笔小技巧 弱self 打印当前类行数列数,多人开发自动适配pch地址,获取设备uid的信息
$(SRCROOT)/PrefixHeader.pch自动适配pch地址 __weak __block typeof(self) weakself = self; __weak typeof(self ...
随机推荐
- java基础篇---反射机制
一.JAVA是动态语言吗? 一般而言,说到动态言,都是指在程序运行时允许改变程序结构或者变量类型,从这个观点看,JAVA和C++一样,都不是动态语言. 但JAVA它却有着一个非常突出的动态相关机制:反 ...
- mysql中文进行全文索引支持问题
先来看看对一个字段做全文索引,作为一个数据库系统需要做哪些工作? 假设一个文章表里面包含几个字段:文章id.文章作者.文章标题.文章内容 比如,我们对文章内容这个字段artilce_content建立 ...
- InstallShield卸载不彻底,残留大量dll文件
今天发现安装包Client装c盘能正常删除,但是放d盘不能删除dll文件. 1.d盘安装程序包 2.检查脚本文件,卸载时通过messagebox打印INSTALLDIR和TARGERDIR,发现均指向 ...
- Aspose Linux下字体找不到报错
http://www.aspose.com/docs/display/cellsnet/Smart+Markers http://www.aspose.com/docs/display/cellsja ...
- IoCopyCurrentIrpStackLocationToNext与IoSetCompletionRoutine的深入理解
1.IoCopyCurrentIrpStackLocationToNext是拷贝本层的IO_STACK_LOCATION 到下一层.在楚狂人的驱动教程中说:如果对irp完成之后的事情有兴趣,并打算在完 ...
- idea properties文件unicode码问题
在git hub上下载了个工程.但是properties文件一直显示不了中文: # \u662F\u5426\u4F7F\u7528\u8FDC\u7A0B\u914D\u7F6E\u6587\u4E ...
- iis 配置多域名,多https
当一个https的请求到达IIS服务器时,https请求为加密状态,需要拿到相应的服务器证书解密请求.由于每个站点对应的证书不同,服务器需要通过请求中不同的主机头来判断需要用哪个证书解密,然而主机头作 ...
- 使用openssl模拟CA和CA证书的签发
使用openssl模拟CA和CA证书的签发 当使用ssl/tls进行加密通信时,必须要有数字证书.若通信只限制在局域网内,可以不向第三方机构申请签发证书,可以通过openssl模拟CA(Cer ...
- 【Django】 积累
■ 数据库的长连接 众所周知,数据库的长连接可以在一定程度上提高整个应用的读写效率,节省创建和销毁数据库连接的成本.Django在1.6版本之后就已经支持了长连接的设置,是在settings中的DAT ...
- PHP判断字符串的包含
PHP语言是一个功能强大的嵌入式HTML脚本语言,它的易用性让许多程序员选择使用.PHP判断字符串的包含,可以使用PHP的内置函数strstr,strpos,stristr直接进行判断.也可以通过ex ...