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);
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);
相关文章推荐
- iOS 获取本地设备相关信息,如:IP地址
- iOS 消息推送 点击app图标 app icon如何获取推送信息 leanCloud 点击app图标 获得推送消息
- iOS 设备获取设备相关信息
- 获取iOS设备的相关信息
- IOS获取设备及APP相应信息
- 获取ios应用的app相关信息
- iOS 怎样获得设备及应用相关信息
- iOS 获取手机设备型号等相关信息
- iOS开发小技巧 获取当前设备/应用程序相关信息
- IOS获得设备信息的三个相关类
- IOS-获取设备和app基本信息
- ios 获取设备相关的信息
- iOS--设备、系统、App相关信息
- 获取iOS App 包名、版本号、设备信息、签名
- iOS 获取设备相关信息
- iOS设备相关信息获取
- IOS获得设备信息的三个相关类
- iOS获取设备相关信息
- IOS--OC获取app应用版本的信息和当前设备的各种信息,跳转到appstore(二)