Although the various APIs that directly get signal strength are blocked. But there is another kind of black magic that can be acquired. That's traversing the uistatusbar.
- (void) getsignalstrength{uiapplication*app =[UIApplication sharedapplication]; Nsarray*subviews = [[[App Valueforkey:@"StatusBar"] Valueforkey:@"Foregroundview"] subviews]; NSString*datanetworkitemview =Nil; for(IDSubviewinchsubviews) { if([Subview iskindofclass:[nsclassfromstring (@"Uistatusbardatanetworkitemview")class]]) {Datanetworkitemview=Subview; Break; } } intSignalstrength = [[Datanetworkitemview valueforkey:@"_wifistrengthbars"] intvalue]; NSLog (@"Signal%d", signalstrength);}
Of course we can also traverse Uistatusbar to get to the network connection type
- (void) getnetworktype{uiapplication*app =[UIApplication sharedapplication]; Nsarray*subviews = [[[App Valueforkeypath:@"StatusBar"] Valueforkeypath:@"Foregroundview"] subviews]; for(IDSubviewinchsubviews) { if([Subview iskindofclass:nsclassfromstring (@"Uistatusbardatanetworkitemview")]) { intNetworktype = [[Subview valueforkeypath:@"Datanetworktype"] intvalue]; Switch(networktype) { Case 0: NSLog (@"NONE"); Break; Case 1: NSLog (@"2G"); Break; Case 2: NSLog (@"3G"); Break; Case 3: NSLog (@"4G"); Break; Case 5: {NSLog (@"WIFI"); } Break; default: Break; } } }}
iOS developed to get WiFi signal strength