(NSString *)getNetWork
{
NSString *result;
NSArray *subviews = [[[[UIApplication sharedApplication] 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”);
result = @”-1”;
break;case 1: NSLog(@"2G"); result = @"2"; break; case 2: NSLog(@"3G"); result = @"3"; break; case 3: NSLog(@"4G"); result = @"4"; break; case 4: NSLog(@"LTE"); result = @"4"; break; case 5: NSLog(@"Wifi"); result = @"1"; break; default: break;
}
return result;
}