Alex Rivera | Logout

Determining 3G vs Edge

Asked 2011-12-06T13:03:48.503
8

I know that the reachability example allows detection of whether network is accessible via Wifi or Cell, but is there a way to determine whether the cell connection is over 3G or EDGE?

Edit
Report

1 Answer

10

Using private APIs, you can read this information directly in the status bar.

https://github.com/nst/MobileSignal/blob/master/Classes/UIApplication+MS.m

+ (NSNumber *)dataNetworkTypeFromStatusBar {

    UIApplication *app = [UIApplication sharedApplication];

    UIStatusBar *statusBar = [app valueForKey:@"statusBar"];

    UIStatusBarForegroundView *foregroundView = [statusBar valueForKey:@"foregroundView"];

    NSArray *subviews = [foregroundView subviews];

    UIStatusBarDataNetworkItemView *dataNetworkItemView = nil;

    for (id subview in subviews) {
        if([subview isKindOfClass:[NSClassFromString(@"UIStatusBarDataNetworkItemView") class]]) {
            dataNetworkItemView = subview;
            break;
        }
    }

    return [dataNetworkItemView valueForKey:@"dataNetworkType"];
}
answered 2012-07-09T17:54:02.160

Your Answer