Post

Replies

Boosts

Views

Activity

Unable to get WiFi rssi value
I want to create a function which will return the rssi value of currently connected WiFi network on my iPhone. I tried fetching the value from status bar but I guess that support is no longer provided in Swift. I have tried the following solution and other solutions with similar approach but it doesn't seem to work now. private func wifiStrength() -> Int? { let app = UIApplication.shared var rssi: Int? guard let statusBar = app.value(forKey: "statusBar") as? UIView, let foregroundView = statusBar.value(forKey: "foregroundView") as? UIView else { return rssi } for view in foregroundView.subviews { if let statusBarDataNetworkItemView = NSClassFromString("UIStatusBarDataNetworkItemView"), view .isKind(of: statusBarDataNetworkItemView) { if let val = view.value(forKey: "wifiStrengthRaw") as? Int { //print("rssi: \(val)") rssi = val break } } } return rssi }
1
0
1.1k
Nov ’23