获取设备和 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 ...
随机推荐
- 【Unity Shader】四、高光反射Specular Shader例子
http://www.cnblogs.com/guxin/p/unity-diffuse-shader-demo.html 在上文中已经学习了漫反射Diffuse Shader和环境光,现在再在此基础 ...
- Java输出字符串格式问题 .UnknownFormatConversionException
今天遇到一个问题,使用JSoup挖掘出的数据一直出错 Exception in thread "main" java.util.UnknownFormatConversionExc ...
- [TestLink]testlink安装
转自:http://www.51testing.com/html/25/465025-3711140.html bitnami参考:https://bitnami.com/stack/testlink ...
- java读取配置文件内容
利用com.typesafe.config包实现 <dependency> <groupId>com.typesafe</groupId> <artifact ...
- Aspose Linux下字体找不到报错
http://www.aspose.com/docs/display/cellsnet/Smart+Markers http://www.aspose.com/docs/display/cellsja ...
- Extjs4.x Tree树刷新,默认选中展开到最后一次选中的节点
跟Extjs3.0不同Extjs4.2的写法如下: idPath = selNode.getPath("id"); tree.getStore().load({ node: tre ...
- vmstat和iostat命令进行Linux性能监控
这是我们正在进行的Linux命令和性能监控系列的一部分.vmstat和iostat两个命令都适用于所有主要的类unix系统(Linux/unix/FreeBSD/Solaris). 如果vmstat和 ...
- 自然语言交流系统 phxnet团队 创新实训 个人博客 (五)
有关我们这个项目:智能自然语言交流系统,所借鉴的技术有: 第一:我们使用了科大讯飞的在线语音转换,涉及的有文本传给云端服务器的文字转换成语音和本地的语音上传给服务器转换成文字. 涉及的相关的代码有: ...
- 使用sessionStorage解决vuex在页面刷新后数据被清除的问题
https://www.jb51.net/article/138218.htm 1.原因 2.解决方法 localStorage没有时间期限,除非将它移除,sessionStorage即会话,当浏览器 ...
- 损失函数Center Loss 代码解析
center loss来自ECCV2016的一篇论文:A Discriminative Feature Learning Approach for Deep Face Recognition. 论文链 ...