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

在项目开发中有时我们需要获得设备或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);


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值