zoukankan      html  css  js  c++  java
  • UIDevice获取设备数据以及如何获取应用信息

    在IOS的APP的应用开发的过程中,有时候需要自动收集用户设备、系统信息、应用信息等等。 
    比如在在app中加入收集用户反馈功能,不仅用户的反馈能够提交到服务器,包括上述信息同时也自动提交到服务器。对用户反馈bug特别有用。

     
    下面是他们的获取方法:
    1. //设备相关信息的获取  
    2.     NSString *strName = [[UIDevice currentDevice] name];  
    3.     NSLog(@"设备名称:%@", strName);  
    4.       
    5.     NSString *strId = [[UIDevice currentDevice] uniqueIdentifier];  
    6.     NSLog(@"设备唯一标识:%@", strId);  
    7.       
    8.     NSString *strSysName = [[UIDevice currentDevice] systemName];  
    9.     NSLog(@"系统名称:%@h", strSysName);  
    10.       
    11.     NSString *strSysVersion = [[UIDevice currentDevice] systemVersion];  
    12.     NSLog(@"系统版本号:%@", strSysVersion);  
    13.       
    14.     NSString *strModel = [[UIDevice currentDevice] model];  
    15.     NSLog(@"设备模式:%@", strModel);  
    16.       
    17.     NSString *strLocModel = [[UIDevice currentDevice] localizedModel];  
    18.     NSLog(@"本地设备模式:%@", strLocModel);  
    19.       
    20.     float version = [[[UIDevice currentDevice] systemVersion] floatValue];  
    21.     NSLog(@"版本号:%f ", version);  
    22.       
    23.     //app应用相关信息的获取  
    24.     NSDictionary *dicInfo = [[NSBundle mainBundle] infoDictionary];  
    25. //    CFShow(dicInfo);  
    26.       
    27.     NSString *strAppName = [dicInfo objectForKey:@"CFBundleDisplayName"];  
    28.     NSLog(@"App应用名称:%@", strAppName);  
    29.       
    30.     NSString *strAppVersion = [dicInfo objectForKey:@"CFBundleShortVersionString"];  
    31.     NSLog(@"App应用版本:%@", strAppVersion);  
    32.       
    33.     NSString *strAppBuild = [dicInfo objectForKey:@"CFBundleVersion"];  
    34.     NSLog(@"App应用Build版本:%@", strAppBuild);  

    但是,在IOS5之后,原来获取IPhone的Device Id的接口:[[UIDevice currentDevice] uniqueIdentifier] 被废弃了。
    uinqueIdentifier在UIDevice.h中的定义如下:
    1. @property(nonatomic,readonly,retain) NSString    *uniqueIdentifier  NS_DEPRECATED_IOS(2_0, 5_0);  
    2. // a string unique to each device based on various hardware info.  
    意思是iOS2.0以上及iOS5.0以下的系统可用,但不建议使用.Apple有可能在ios5.0之后删除该函数. 
    经过测试,未越狱的iPhone,系统版本为5.0.1,依然可以获取UDID.。
  • 相关阅读:
    生成证书时Distribution下面App Store and Ad Hoc 选项不能选择的原因及解决办法
    ios 实现版本更新检查
    ios 同步Get请求的实现
    UI设计规范整理一iOS字体和切图及规范
    Mac下使用抓包工具--Charles进行抓包
    iOS 审核被拒
    Xcode 9 compiling IB documents for earlier than ios 7 is no longer supported
    解决JSON包含HTML标签无法显示的问题
    OC与swift相互调用
    UIApplication深入研究
  • 原文地址:https://www.cnblogs.com/pjl111/p/4230184.html
Copyright © 2011-2022 走看看