NEHotspotConfigurationManager not creating/joining hotspot
Asked Answered
I

3

3

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.

Implicit answered 26/9, 2017 at 10:52 Comment(4)
You're probably seeing success because the configuration was successfully added. That is, it's added like any other "saved" WiFi you may have set up in the past (e.g., your home network, the office wifi). At that point, I can only guess why it failed. My short list would be WiFi signal strength or that the configuration you successful saved had a typo or something invalid.Saltworks
@Saltworks : Well.. i think i won't be able to create a hotspot from code(which i was hoping i could, hence the attempt). i can only join one. However i am not quite sure. Can i create a hotspot from code, or can only join one ?Implicit
You're right. No, you can't create a new hotspot from code on iOS. NEHotspotConfiguration simply makes it a little easier to connect to a pre-existing WiFi network/WiFi peripheral.Saltworks
@PawanJoshi I have same issue. How can you resolved?Hooey
V
1

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.

Vitrics answered 3/1, 2018 at 6:43 Comment(0)
M
1

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.

Mroz answered 20/3 at 10:14 Comment(0)
Z
-1

Enable Hotspot on App Id configure services

Enable Hotspot on App Id configure services

After Enable Hotspot Configuration

After Enable Hotspot Configuration

Zane answered 6/12, 2017 at 11:58 Comment(4)
Hello, for some reason I cant get hotspot as one of the options in capabilities. Any suggestions on that?Rothman
@MohammadBashirSidani it is because you need a developer account for this to capabilities to workLargo
Thanks!! I found this out since when I removed my account from xCode, it was available. ticking it it showed I need a paid developer account.Rothman
Where do we get to this screen in order to configure it?Homomorphism

© 2022 - 2024 — McMap. All rights reserved.