Here i posted code that is working till ios 15
if let statusBarManager = UIApplication.shared.keyWindow?.windowScene?.statusBarManager,
let localStatusBar = statusBarManager.value(forKey: "createLocalStatusBar") as? AnyObject,
let statusBar = localStatusBar.value(forKey: "statusBar") as? NSObject,
let _statusBar = statusBar.value(forKey: "_statusBar") as? UIView,
let currentData = _statusBar.value(forKey: "currentData") as? NSObject,
let celluar = currentData.value(forKey: "cellularEntry") as? NSObject,
let signalStrength = celluar.value(forKey: "displayValue") as? Int { print(signalStrength)
}
To build on MobileTen’s response…
iOS has no supported API to get real-time cellular signal strength [1]. Out there on the ’net you will find various folks promulgating various unsupported techniques for this. These are likely to break as we tighten up platform security.
The situation for Wi-Fi is more nuanced but your code and tags suggest that your focus is cellular.
Taking a step back, why do you need this info? What would you do with it once you got it.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] You can get aggregate info from the MXCellularConditionMetric
class.