I need in my application to get continuously strength of WiFi. I am trying to implement Key-Value Observing approach and get this info from StatusBar this way:
[UIApplication.sharedApplication() addObserver:signalListener
forKeyPath:@"IDontKnowWhat"
options:NSKeyValueObservingOptionNew
context:NULL];
But this gives me error:
Called object type 'UIApplication * _Nonnull' is not a function or function pointer
And later I would like to get signal strength this way:
NSArray *subviews = [[[IDontKnowWhat valueForKey:@"statusBar"] valueForKey:@"foregroundView"] subviews];
NSString *wifiNetworkItemView = nil;
for (id subview in subviews) {
if([subview isKindOfClass:[NSClassFromString(@"UIStatusBarDataNetworkItemView") class]]) {
wifiNetworkItemView = subview;
}
}
int wifiSignalStrength = [[wifiNetworkItemView valueForKey:@"wifiStrengthRaw"] intValue];
Can someone give me advise, if it is possible to implement KVO on statusBar of UIApplication sharedApplication? Or is there any other way to get continuously WiFi strength?