iOS 13.2 message: nehelper sent invalid result code [1] for Wi-Fi information request
It eventually turned out, that a third party framework that my app uses, launches those calls to CNCopyCurrentNetworkInfo.
After I added WiFi access capabilities as described here to the app itself the error message disappeared
How to fetch SSID in iOS device with iOS 13
Using the code provided on iOS 14 I got the following error:
nehelper sent invalid result code [1] for Wi-Fi information request
Searching for that error took me to this question
Solution:
The requesting app must meet one of the following requirements:
The app uses Core Location, and has the user’s authorization to use
location information.The app uses the NEHotspotConfiguration API to configure the current
Wi-Fi network.The app has active VPN configurations installed.
An app that fails to meet any of the above requirements receives the
following return value:An app linked against iOS 12 or earlier receives a dictionary with
pseudo-values. In this case, the SSID is Wi-Fi (or WLAN in the China
region), and the BSSID is 00:00:00:00:00:00.An app linked against iOS 13 or later receives NULL.
Important
To use this function, an app linked against iOS 12 or later must
enable the Access WiFi Information capability in Xcode.
I also confirmed that this in fact works on iOS 14 once you request location permission.
import CoreLocation
import UIKit
import SystemConfiguration.CaptiveNetwork
final class ViewController: UIViewController {
var locationManager: CLLocationManager?
override func viewDidLoad() {
super.viewDidLoad()
locationManager = CLLocationManager()
locationManager?.delegate = self
locationManager?.requestAlwaysAuthorization()
}
func getWiFiName() -> String? {
var ssid: String?
if let interfaces = CNCopySupportedInterfaces() as NSArray? {
for interface in interfaces {
if let interfaceInfo = CNCopyCurrentNetworkInfo(interface as! CFString) as NSDictionary? {
ssid = interfaceInfo[kCNNetworkInfoKeySSID as String] as? String
break
}
}
}
return ssid
}
}
extension ViewController: CLLocationManagerDelegate {
func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
if status == .authorizedAlways || status == .authorizedAlways {
let ssid = self.getWiFiName()
print("SSID: \(String(describing: ssid))")
}
}
}
Output: SSID: YaMomsWiFi
Don't forget to include the wifi entitlement, and the necessary keys in your plist for location permission.
App terminated due to cpu use in iOS 13.2
It turned out, that a third party framework that I am using launches calls to CNCopyNetworkInfo in second intervals. These calls could not fullfilled as my App had no WiFi capabilities enabled and thus the calls to CNCopyNetworkInfo caused small memory leaks that added up over time.
After enabling WiFi access capabilities the memory leaks vanished.
Transport security has blocked a cleartext HTTP
If you are using Xcode 8.0+ and Swift 2.2+ or even Objective C:
If you want to allow HTTP connections to any site, you can use this keys:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
If you know which domains you will connect to add:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>example.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
Related Topics
Tabbarcontroller Adding Custom Button Not Clickable Issue
How to Make One Side of a Div Pointy with CSS
Does "Let _ = ..." (Let Underscore Equal) Have Any Use in Swift
Uibutton Target Action Inside Uiview
Core Data Nstimeinterval Using an Accessor Directly Is Buggy
Get Path to Subdirectory in Resources Folder
How to Get System Device Language, Swift iOS
Atos Does Not Symbolicate System Frameworks/Libraries Properly
How to Present Uiview (Xib) as Alert View in Swift
Notification in Swift Every Day at a Set Time
Receipt Validation in iOS Returns Incorrect Info During Sandbox Testing
Are Private Frameworks Supported on iOS
My App Is Getting Crashed on UIdocumentpickerviewcontroller
How to Add a Lock Screen Widget (Requiring iOS 16) and Still Support iOS 15
How to Call Objective-C Instancetype Method in Swift
Detecting Double and Single Tap on Uitableviewcell to Perform Two Action
How to Set Style of the Statusbar Embedded in a Navigation Controller on iOS13
Why Use Corebluetooth Connectperipheral Did Not Call Delegate Methods in iOS8