NEHotspotConfigurationManager not creating/joining hotspot

3k views Asked by At

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.

3

There are 3 answers

4
Virajkumar Patel On

Enable Hotspot on App Id configure services

Enable Hotspot on App Id configure services

After Enable Hotspot Configuration

After Enable Hotspot Configuration

0
christo16 On

The network is being added to the device's known network list, making it available to be auto joined. Unless you have a nearby network named "testNetwork" it will always fail to join.

0
Mohit Negi On

If you enter the ssid with spaces then it will not work.

In my case my ssid contained spaces & i got the success in console but with error alert. After removing the spaces it's working fine.