I’m encountering an unexpected issue while using NEHotspotConfigurationManager.shared.apply(...) to connect to a Wi-Fi network. Specifically, I’m receiving a userDenied error, even though the user did not interact with any system prompt.
Here’s a version of the code I’m using:
let config = NEHotspotConfiguration(ssid: ssid, passphrase: passphrase, isWEP: false) // config.joinOnce = true NEHotspotConfigurationManager.shared.apply(config) { error in if let err = error { let nsErr = err as NSError mlog("err.code:\(nsErr.code)") if nsErr.code == NEHotspotConfigurationError.alreadyAssociated.rawValue { self.findWiFiListAndConnect(ssid, passphrase, overtimeSec, timeStart) } else { self.cmdDelegateQueue.async { self.delegate?.wifiClose(nsErr.code) } } } }
The error returned is:
wifiClose status: 7
Which corresponds to NEHotspotConfigurationError.userDenied. According to the official Apple documentation, this error should only occur when the user explicitly cancels the system dialog. However, in my case: • No system dialog appears. • The user does nothing, yet the error is still returned. • This issue does not happen every time, but it has been observed across multiple devices.
Additional info: • iOS version: 18.5 • Device model: iPhone • joinOnce is not set (defaults to false) • Existing configuration is removed using removeConfiguration(...) before applying
Is it possible that under certain system states (e.g. backgrounded, network restrictions, or app permissions), iOS silently fails without showing the prompt?
Has anyone else encountered this issue, or does anyone know what could cause this behavior?
Any help is greatly appreciated!
Error .unknown
(11) is weird. I’m not sure why we have that and .internal
(8).
Problems like this are definitely bugworthy, but there’s a wrinkle. For the bug to be actionable we really need a sysdiagnose log, and that’s hard to get for such transient errors.
If you have a set of reasonably technical beta testers then you could enlist their support in the investigation. I offer some suggestions for how to do that in Using a Sysdiagnose Log to Debug a Hard-to-Reproduce Problem
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"