ios获取手机状态idfaidfv网络类型分辨率获取运营商ip-创新互联
//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;
}
//获取ip
- (NSString *)getIp
{
//获取ip -(NSDictionary *)deviceWANIPAdress{
NSError *error;
NSURL *ipURL = [NSURL URLWithString:@"http://pv.sohu.com/cityjson?ie=utf-8
"];
NSMutableString *ip = [NSMutableString stringWithContentsOfURL:ipURL encoding:NSUTF8StringEncoding error:&error];
//判断返回字符串是否为所需数据
if ([ip hasPrefix:@"var returnCitySN = "]) {
//对字符串进行处理,然后进行json解析
//删除字符串多余字符串
NSRange range = NSMakeRange(0, 19);
[ip deleteCharactersInRange:range];
NSString * nowIp =[ip substringToIndex:ip.length-1];
//将字符串转换成二进制进行Json解析
NSData * data = [nowIp dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary * dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
return [dict valueForKey:(@"cip")];
}else{
return @"ip";
}
}
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
当前标题:ios获取手机状态idfaidfv网络类型分辨率获取运营商ip-创新互联
当前路径:http://scyanting.com/article/dsocpc.html