ios获取手机状态 idfa idfv 网络类型 分辨率 获取运营商
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ios获取手机状态 idfa idfv 网络类型 分辨率 获取运营商相关的知识,希望对你有一定的参考价值。
//idfa
[[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
//idfv
[[[UIDevice currentDevice] identifierForVendor] UUIDString];
//网络类型
- (NSString *) getNet
{
UIApplication *application = [UIApplication sharedApplication];
NSArray *subviews = [[[application valueForKey:@"statusBar"] valueForKey:@"foregroundView"]subviews];
NSNumber *dataNetWorkItemView = nil;
for (id subView in subviews) {
if ([subView isKindOfClass:[NSClassFromString(@"UIStatusBarDataNetworkItemView") class]]) {
dataNetWorkItemView = subView;
break;
}
}
switch ([[dataNetWorkItemView valueForKey:@"dataNetworkType"] integerValue]) {
case 0:
NSLog(@"No wifi or cellular");
return @"null";
break;
case 1:
NSLog(@"2G");
return @"2G";
break;
case 2:
NSLog(@"3G");
return @"3G";
break;
default:
NSLog(@"Wifi");
return @"Wifi";
break;
}
return @"null";
}
//分辨率
- (NSString *) getFbl
{
//屏幕尺寸
CGRect rect = [[UIScreen mainScreen] bounds];
CGSize size = rect.size;
CGFloat width = size.width;
CGFloat height = size.height;
NSLog(@"print %f,%f", width, height);
//分辨率
CGFloat scale_screen = [UIScreen mainScreen].scale;
return [NSString stringWithFormat:@"%d*%d", (int)(width * scale_screen), (int)(height * scale_screen)];
}
//获取运营商
- (NSString *)getOp
{
NSString * ret = @"";
CTTelephonyNetworkInfo *info = [[CTTelephonyNetworkInfo alloc] init];
CTCarrier *carrier = [info subscriberCellularProvider];
if (carrier == nil)
{
[info release];
return @"null1";
}
NSString *code = [carrier mobileNetworkCode];
if (code == nil)
{
[info release];
return @"null2";
}
if ([code isEqualToString:@"00"] || [code isEqualToString:@"02"] || [code isEqualToString:@"07"])
{
ret = @"China Mobile";
}
if ([code isEqualToString:@"01"] || [code isEqualToString:@"06"])
{
ret = @"China Unicom";
}
if ([code isEqualToString:@"03"] || [code isEqualToString:@"05"])
{
ret = @"China Telecom";
}
if ([code isEqualToString:@"20"])
{
ret = @"China Tietong";
}
[info release];
return ret;
}
本文出自 “陪你度过漫长岁月” 博客,请务必保留此出处http://4774721.blog.51cto.com/4764721/1792324
以上是关于ios获取手机状态 idfa idfv 网络类型 分辨率 获取运营商的主要内容,如果未能解决你的问题,请参考以下文章
Google 的 Google Advertising ID(GAID) 和 Apple 的 IDFA 可以冲突吗?
移动端设备标识码-DeviceID、IMEI、IDFA、UDID
Google Analytics iOS - 没有跟踪 ID 来为 App+Web 媒体资源启用 IDFA 收集
iOS 上的 IDFA 和 IDFV 仍在使用 XCode 11 构建