How to get the SSID of the surrounding Wi-Fi. If you apply for the NEHotspotHelper API permission, please advise?

How to get the SSID of the surrounding Wi-Fi. If you apply for the NEHotspotHelper API permission, please advise?

Replies

Probably something like:

...
fileprivate extension ExampleHotspotHelper {

        static let hotspotHandler: NEHotspotHelperHandler = { command in

                switch command.commandType {
                case .filterScanList:
                        let networkList = command.networkList
                        NSLog("FilterScanList:\n\(networkList.map { String(describing: $0) }.joined(separator: "\n"))")
                
                ....
                }
        }
}
...

NB! this is executed only when end user goes to Settings->Wifi and phone updates list of nearby networks.

How to get the SSID of the surrounding Wi-Fi.

iOS has no general-purpose API to return Wi-Fi scan results. There are both business and technical reasons why

NEHotspotHelper
will not work for that. See this post for more.

There may be a special purpose API that suits your needs, although to comment on that I’d need to know more about what you intend to do with this information.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hello,


Because our device is a Wi-Fi device, we need users to configure Wi-Fi linked to the Wi-Fi device in our application, because we don't know that the user wants to link to the Wi-Fi, so the user needs it. To select the Wi-Fi you want to link, we need to provide the user with a list of available Wi-Fi in the application. Let the user select Wi-Fi, enter the Wi-Fi password, and then pass the information through UDP. Sending to a Wi-Fi device to reach a network that modifies Wi-Fi device links, allowing the device to link to the internet, so that the user can remotely operate the Wi-Fi device. However, I applied for the NEHotspotHelper API not to pass. So I would like to consult under?


Thank you

First up, I’m going to use accessory, not device, here. That’s because Apple generally uses device to refer to the iOS device itself.

Second, I’m sorry but I’m having a hard time parsing your text. The following is my best guess based on that parsing. If I got anything wrong, please let me know.

Let the user select Wi-Fi, enter the Wi-Fi password, and then pass the information through UDP.

If you’re app is in UDP communication with your accessory, does that mean the iOS device has already joined the accessory’s network. So the sequence runs something like this:

  1. Accessory boots up in default mode, advertising a Wi-Fi network.

  2. The user (or your app, using

    NEHotspotConfigurationManager
    ) forces the iOS device on to the accessory’s Wi-Fi network.
  3. Your app starts communicating with your accessory.

  4. Your goal is:

    1. Scan for nearby Wi-Fi networks.

    2. Have the user choose a network.

    3. Have the user enter the network’s password.

    4. Send that info to your accessory.

    5. Have your accessory join that network?

Is that right?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Hello


Yes, I can't scan the surrounding wifi network now. So I want to ask what is the solution?



Thank you.

As I mentioned before, iOS does not have a general-purpose Wi-Fi scanning API, so there’s no direct solution here. However, I can see some options:

  • If your main goal is to get the Wi-Fi accessory on the user’s standard network, you can implement Wireless Accessory Configuration (WAC). This makes the whole user experience much more pleasant.

    See QA1942 iOS Wi-Fi Management APIs for links to WAC information.

  • If WAC isn’t an option, your choices are more limited. If you have any control over the accessory’s firmware, you can have it scan for Wi-Fi networks on your behalf. That is, at step 4.1 in my previous post, don’t scan for Wi-Fi networks on the iOS device but instead send a command to your accessory to have it scan for Wi-Fi networks and return you the result.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thank you