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.
Use CoreTelephony and
CTTelephonyCenter
observers:Register the handler in another function:
Adapted from the iPhone Dev Wiki article on CTIndicators.
These methods are no longer in any iOS SDKs greater than 8.4 (?) I believe. To access them, create a new header with to extern the functions and constants:
I use private APIs too.. But I get this Signal strength from the (visible) Status bar.
Hope this helps!!