NEHotspotConfigurationManager not creating/joining hotspot

Viewed 2740

I am trying to create/add a Hotspot configuration in iOS 11 installed device.

My code is as follows

let hotspotConfig = NEHotspotConfiguration(ssid: "testNetwork")
hotspotConfig.joinOnce = true
NEHotspotConfigurationManager.shared.apply(hotspotConfig) { (configurationError) in
    if configurationError != nil {
      print("error")
      print(configurationError!.localizedDescription)
    } else {
      print("success")
    }        
}

When i try to run the code. Device prompts for permissions as the following:-

"AppName" wants to join Wi-Fi Network "testNetwork"

But on tapping "Join", I am getting the following response

Unable to join the network "testNetwork"

However, on debug console "success" is getting printed.

Please tell me what am i doing wrong.

2 Answers
Related