1

I'm trying to adapt the code of my app to the new iOS version (iOS 13).

I need to get the information from the Subviews from the Statusbar of the phone, specifically the "cellularEntry", the display value.

This is how I used to do it in older iOS version than iOS 13:

UIApplication *app = [UIApplication sharedApplication];
id statusBar = [app valueForKey:@"statusBar"];
NSArray subviews = [[statusBar valueForKey:@"statusBar"] valueForKey:@"currentData"];
id dataNetworkItemView = [[subviews valueForKey:@"cellularEntry"] valueForKey:@"displayValue"];

This is how I'm trying to do it for iOS 13:

UIApplication *app = [UIApplication sharedApplication];
UIView statusBar = [[UIView alloc]initWithFrame:app.keyWindow.windowScene.statusBarManager.statusBarFrame];
NSArray subviews = [statusBar subviews];
id dataNetworkItemView = [[subviews valueForKey:@"cellularEntry"] valueForKey:@"displayValue"];

My problem is that the subviews array in the second case, is always empty, so I can not get any value.

It would be really helpful if you could suggest me the right way to get the subviews in iOS 13 or an alternative to get CellularEntrey value.

CPI
  • 786
  • 1
  • 5
  • 18
  • The status bar belongs to the runtime and has no subviews. This was always illegal and unsupported and now it has stopped working. – matt Sep 26 '19 at 13:17
  • As @matt said, accessing values using `[subviews valueForKey:@"cellularEntry"]` was never really supported. What information are you trying to extract from the status bar and what do you want to do with this information? I couldn't find out what "cellularEntry" is. – pepsy Sep 26 '19 at 13:30
  • Thanks, both for your comments. Basically I'm trying to get the signal strength, specifically "signalStrengthRaw" & "signalStrengthBars", however, I don't know another way to get them. – CPI Sep 26 '19 at 13:44
  • A search (https://stackoverflow.com/search?q=ios+signal+strength) suggests that there is no public API for getting that information. It also confirms that the trick of trying peek at the status bar is unsupported and likely to get the app rejected from the App Store. – matt Sep 26 '19 at 13:58
  • @matt, until iOS 13 it has been supported because it was working, additionally, this is just for testing purposes, I'm not planning to upload the app to the AppStore. This [Chinese post](https://juejin.im/post/5d650aede51d4561c41fb854) looks like a solution, but after testing it, the statusBar is still an empty object. – CPI Sep 26 '19 at 14:15
  • This would be a great use case to submit as an enhancement request to the Apple feedback assistant, and I urge you to do so. – matt Sep 26 '19 at 14:26
  • @matt, first, I checked the Stackoverflow answer that you marked as the duplicated one. It is talking about iOS 8.3, and it is a question 4 years ago. My question is similar but talking about the new iOS version iOS 13, so this shouldn't be marked as duplicated. Second, could you point to me where is the Apple documentation that says that this functionality is not supported, please? I'm having some difficulties to find it. – CPI Sep 26 '19 at 14:52
  • The answers to the other question (and many others you can find in the search link I gave) show that there was once a Core Telephony API for getting signal strength but it was withdrawn, and they also caution that using key-value coding to access the status bar's subviews is just a hack and can get the app barred from the App Store. – matt Sep 26 '19 at 14:57

0 Answers0