I am trying to get the signal strength in dBm for the carrier, wifi, 3g, and 4g.
I am currently using this code to get the carrier's and wifi from the status bar and I would like to know if there is another way or a better way? Also how could I get it for 3g and 4g?
UIApplication *app = [UIApplication sharedApplication];
NSArray *subviews = [[[app valueForKey:@"statusBar"] valueForKey:@"foregroundView"] subviews];
NSString *dataNetworkItemView = nil;
NSString *wifiNetworkItemView = nil;
for (id subview in subviews) {
if([subview isKindOfClass:[NSClassFromString(@"UIStatusBarSignalStrengthItemView") class]]) {
dataNetworkItemView = subview;
}
if([subview isKindOfClass:[NSClassFromString(@"UIStatusBarDataNetworkItemView") class]]) {
wifiNetworkItemView = subview;
}
}
int carrierSignalStrength = [[dataNetworkItemView valueForKey:@"signalStrengthRaw"] intValue];
int wifiSignalStrength = [[wifiNetworkItemView valueForKey:@"wifiStrengthRaw"] intValue];
It doesn't matter if any methods I use are private or not.