您的位置:首页 > 移动开发

iOS获得设备相关信息,获取app相关信息

2016-09-01 11:47 302 查看
在项目开发中有时我们需要获得设备或app的一些信息并传递给后台,如新注册用户奖励现金20元,为了防止恶意注册,就需要拿到设备信息,只要该设备注册过,再在该设备上注册的用户则无奖励









 
   
UIDevice *device = [[UIDevice
alloc] init];
   
NSLog(@"设备所有者名称  %@  ",device.name);//设备所有者名称
   
NSLog(@"设备类别  %@",device.model);//设备leibie
   
NSLog(@"本地化版本  %@",device.localizedModel);//本地化版本
   
NSLog(@"当前系统版本  %@",device.systemVersion);//当期版本
   
NSLog(@"当前系统  %@",device.systemName);//当前系统
   
NSLog(@"系统唯一标示符  %@",[[[UIDevice
currentDevice ] identifierForVendor]
UUIDString]);//唯一标示
   
NSLog(@"电量   %f",[[UIDevice
currentDevice] batteryLevel]);//输出-1为模拟器  输出0-1为真机

    
   
NSArray *languageArray = [NSLocale
preferredLanguages];
   
NSString *language = [languageArray
objectAtIndex:0];
   
NSLog(@"语言:%@", language);//语言
   
NSLocale *locale = [NSLocale
currentLocale];
   
NSString *country = [locale localeIdentifier];
   
NSLog(@"国家:%@", country);
//国别

    
   
//获得运营商信息
   
CTTelephonyNetworkInfo *info = [[CTTelephonyNetworkInfo
alloc] init];

 
   
//  获取运行商的名称
   
CTCarrier *carrier = [info subscriberCellularProvider];
   
NSString *mCarrier = [NSString
stringWithFormat:@"%@",[carrier
carrierName]];
   
NSLog(@"%@", mCarrier);

   
//app应用相关信息的获取
   
NSDictionary *dicInfo = [[NSBundle
mainBundle] infoDictionary];
   
NSLog(@"应用所有信息 %@",dicInfo);
   
NSString *strAppName = [dicInfo
objectForKey:@"CFBundleDisplayName"];
   
NSLog(@"App应用名称:%@", strAppName);
   
NSString *strAppVersion = [dicInfo
objectForKey:@"CFBundleShortVersionString"];
   
NSLog(@"App应用版本:%@", strAppVersion);
   
NSString *strAppBuild = [dicInfo
objectForKey:@"CFBundleVersion"];
   
NSLog(@"App应用Build版本:%@", strAppBuild);
   
NSString *strAppBundleIdentifier = [dicInfo
objectForKey:@"CFBundleIdentifier"];
   
NSLog(@"App应用唯一标示符:%@", strAppBundleIdentifier);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息