获取设备和 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 ...
随机推荐
- 手记:配置IIS服务器,支持sis、SISX、3GP、ADP、AMR、JAD、JAR、MMF、MFM、PMD、UMD等文件下载
发此博文原因是遇到一个 手机端读取服务器端.amr格式文件失败的例子. 反复测试发现从服务端无法播放,或下载.amr格式的文件.就想到可能是服务器站点托管服务 IIS不支持对.amr格式的解析,意 ...
- python parse xml using DOM
demo: import xml.dom.minidom dom=xml.dom.minidom.parse('sample.xml')root = dom.documentElementcc=dom ...
- Android基础——Fragment与Activity交互
今天继续讲解Fragment组件的特性,主要是跟Activity的交互和生命周期的关系,我们前面已经说过Fragment是依赖于Activity的,而且生命周期也跟Activity绑定一起.下面我们看 ...
- myeclipse开发安装C++
经过若干google之后(百度就不用说了),又经过了若干尝试,终于用最简单的步骤配起来了.(一些比较旧的文章写的太繁杂了,随着各个工具的升级,搭建环境很简单了). 前言:写博客不是为了炫 ...
- [strace]跟踪进程的系统调用
转自:https://www.cnblogs.com/ggjucheng/archive/2012/01/08/2316692.html 简介 strace常用来跟踪进程执行时的系统调用和所接收的信号 ...
- 根据map键值对,生成update与select语句,单条执行语句
方法 constructUpdateSQL private static String constructUpdateSQL(String tableName, List<Map<Stri ...
- PCL中IO模块和类的介绍
I/O模块中共有21个类 (1)class pcl::FIleReader:定义了PCD文件的读取接口,主要用作其他读取类的父类 pcl::FileReader有pcl::PCDReader和pc ...
- 使用JAAS登录kerberos服务器
java代码: package com.snsprj.jaas0822; import javax.security.auth.*; import javax.security.auth.callba ...
- WebRTC网关服务器单端口方案实现
标准WebRTC连接建立流程 这里描述的是Trickle ICE过程,并且省略了通话发起与接受的信令部分.流程如下: 1) WebRTC A通过Signal Server转发SDP OFFER到Web ...
- 线段树 + 区间更新 ----- HDU 4902 : Nice boat
Nice boat Time Limit: 30000/15000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Tot ...