11

I would like to scan for nearby SSIDs of the Wi-Fi networks periodically (without connecting to it) and implement an SSID filter (one or multiple). Once a match is found a back-end API call is initiated.


I have done a quick research on the Hotspot Helper framework in iOS 10. I found that, these APIs are not designed for the use I’ve identified.


Seems like, iOS 11 now allows apps to manage Wi-Fi configurations programmatically. Apple added a network extension for hotspot configuration methods and properties. Please click here to see the changes. 


My question here is, can I achieve my goal through the newly iOS 11 hotspot configuration class? Or does this provide the SSID of a known network or the currently connected one?



Any help on this is highly appreciated.

Shamsudheen TK
  • 30,739
  • 9
  • 69
  • 102

3 Answers3

12

Unfortunately, we can't achieve this in iOS.

When I learned about NEHotspotConfiguration, I was initially excited, because I was hoping we could automate this process. However, it doesn't look like there's a way to retrieve a list of currently available SSIDs, which makes NEHotspotConfiguration much less useful for our use case.

Shamsudheen TK
  • 30,739
  • 9
  • 69
  • 102
  • I want to scan nearby WiFi networks and get their received signal value (RSS) on my iPhone. I don't want to connect my device with WiFi networks. Is it possible using `NEHotspotConfiguration`? Is there any sample code snipped available for Objective-C? – santobedi Jun 20 '18 at 05:36
  • [This](https://stackoverflow.com/questions/31555640/how-to-get-wifi-ssid-in-ios9-after-captivenetwork-is-deprecated-and-calls-for-wi/49323539?noredirect=1#comment88883579_49323539) thread says that it is possible. I'm bit confused. I've just started digging for WiFi signal strength. Earlier I used to work with Bluetooth signal strength, which I can work efficiently. – santobedi Jun 20 '18 at 10:30
  • 4
    No, you can't. The solution you provided will work in the iOS 9 GM. It will not work on other versions. I already done a good research on this. – Shamsudheen TK Jun 20 '18 at 11:32
  • so there is no way that we can get list of wifi networks? – shaqir saiyed Aug 08 '19 at 11:19
3

Not possible.

I enabled the NEHotspotHelper permission and tried on a Demo app. Even though Apple does allow you to configure wifi connections, in order to get the list of available networks, you need to open the Settings > WiFi page to get the list. This API can NOT offer the ability to scan the WiFi list in background, not to mention periodically.

It's a pity for developers, but I think it's good for iOS users, to protect privacy and safety by strict restriction of the API usage.

Max Turner
  • 138
  • 9
陈健 Mark
  • 341
  • 2
  • 14
0

As per my understanding you can achieve this using following code

      let targetSsid = getCurrentSSID()
    let targetAnnotation: String = targetSsid!

    //let options: [String: NSObject] = [kNEHotspotHelperOptionDisplayName : targetAnnotation as NSObject]
    //let queue: DispatchQueue = DispatchQueue(label: "com.myapp.appname", attributes: DispatchQueue.Attributes.concurrent)

    NSLog("Started wifi list scanning.")


    let options: [String: NSObject] = [
        kNEHotspotHelperOptionDisplayName: targetAnnotation as NSString
    ]

    let queue = DispatchQueue(label: "com.example.test")

    let isAvailable = NEHotspotHelper.register(options: options, queue: queue) { (command) in
        switch command.commandType {
        case .evaluate,
             .filterScanList:
            let originalNetworklist = command.networkList ?? []
            let networkList = originalNetworklist.compactMap { network -> NEHotspotNetwork? in
                print("networkName: \(network.ssid); strength: \(network.signalStrength)")
                if network.ssid == targetSsid {
                    network.setConfidence(.high)
                    //network.setPassword(targetPassword)
                    return network
                }
                return nil
            }
            let response = command.createResponse(.success)
            response.setNetworkList(networkList)
            response.deliver()
        default:
            break
        }
    }

Only problem is that you have to be at wifi settings page to get the list of all available SSIDs along with their signal strength.

Dinesh
  • 929
  • 7
  • 25