iOS 13.2 Message: Nehelper Sent Invalid Result Code [1] for Wi-Fi Information Request

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:

Sample Image

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



Leave a reply



Submit