iPhone get a list of all SSIDs without private library
Asked Answered
E

6

35

Is it possible the get a list of all available SSIDs on the iPhone without using a private library?

I read iPhone get SSID without private library which is about getting details about the current network.

This answer mentions:

If you jailbreak your device you can use the Apple80211 private framework to look up the available Wi-Fi networks and their signal strength. But that also means your app will get rejected.

Apple has the CaptiveNetwork API but there doesn't seem to be a solution to get a list of all available networks. It seems it's only possible to do so with using the Apple80211 private library, or connecting to all of them.

Am I missing something, or is there no solution?

Et answered 13/3, 2012 at 12:56 Comment(1)
For the same question but with the ability to use private libraries, see #25784594Uboat
C
31

Without the use of private library (Apple80211) you can only get the SSID of the network your device is currently connected to.

Cletacleti answered 13/3, 2012 at 13:30 Comment(5)
@grubernd: i wish i could give you a different one :)Cletacleti
we could get SSID,BSSID and SSID DATA without using private api but just using CaptiveNetwork class in SystemNetworkConfiguration.framework.Monofilament
AS far as i know you can retrieve supported (preprogrammed) SSIDs - not the ones that are currently in range. And of course SSID of currently connected network. If I am wrong please add an answer with code and I will contact OP to accept your answer.Cletacleti
@RokJarc I need all ranged wifi list. Can you please suggest any available private library to achieve this. Also please let me know if it is possible to do without private library in newer ios version or not.Camise
@MiteshDobareeya: i haven't met with this topic for a long time so i can't be of much help. Check KeniLang's answer to this post. Seems like a good starting point.Cletacleti
U
6

Some new APIs have been released as part of the Network Extension in iOS 9 and iOS 11. While neither allows you to scan for networks while your app is running, they both allow you to do related tasks. E.g. you can scan for networks while the Settings Wi-Fi page is running using Hotspot Helper, and you can make it easier for a user to join a network using either of these.

Here's a comparison of the two frameworks.

Hotspot Helper

  • NEHotspotHelper (introduced in iOS 9, WWDC 2015).
  • Requires special permission from Apple.
  • Requires the com.apple.developer.networking.HotspotHelper entitlement.
  • For step-by-step instructions to get this working, see this answer.
  • Allows you to participate in the discovery/authentication to a Wi-Fi network via the Wi-Fi screen in the Settings app. You register to be notified when networks are being scanned (e.g. when the user launches Wi-Fi in the Settings app), and you can automatically pre-fill the password and display an annotation near the network name. The user still needs to tap on the network name to connect, but it won't prompt for a password if you pre-filled it.

    enter image description here

Hotspot Configuration

  • NEHotspotConfigurationManager (introduced in iOS 11, WWDC 2017).
  • Does not require special permission from Apple.
  • Requires the com.apple.developer.networking.HotspotConfiguration entitlement.
  • Allows you to initiate a connection to a Wi-Fi network. You give it a list of SSIDs/Passwords that should be connected to while your app is running. It will present a dialog asking the user if they want to connect to the network.

    enter image description here

Uboat answered 24/9, 2018 at 6:4 Comment(0)
C
4

Since iOS 9, you can use NEHotspotHelper to get a list of SSIDs. But you have to get the com.apple.developer.networking.HotspotHelper entitlement from Apple by sending a request.

Check https://developer.apple.com/documentation/networkextension/nehotspothelper for more infomation.

Consecution answered 21/8, 2017 at 9:32 Comment(1)
NEHotspotNetwork will only return a list of networks when the user navigates to the Wi-Fi page in Settings. See this answer for more details.Uboat
B
1

Step 1: add the framework SystemConfiguration.framework
Step 2: import following header file

import SystemConfiguration
import SystemConfiguration.CaptiveNetwork

Step 3: Now Use Code:

func getUsedSSID()->String {

       let interfaces = CNCopySupportedInterfaces()

        if interfaces != nil {

            let interfacesArray = CFBridgingRetain(interfaces) as! NSArray

            if interfacesArray.count > 0 {

                let interfaceName = interfacesArray[0] as! String
                let unsafeInterfaceData = CNCopyCurrentNetworkInfo(interfaceName)! as Dictionary
                let SSIDName = unsafeInterfaceData["SSID"] as! String
                print(SSIDName)/* here print recentally used wifi name*/
                return SSIDName
            }else{
                return "0"
            }
        }else{
            return "0"
        }
    }
Backset answered 31/5, 2016 at 11:30 Comment(6)
can u type the objective c version plsDiscreet
Only getting connected SSID,I want to fetch all ranged SSID. Can you please help me to do same ?Gidgetgie
@hiteshlandge is there any possibility for getting all ranged wifi SSID ? Please provide any hint or example code.Camise
Please delete this answer and/or repost it as the answer to someone who asked how to get the SSID of the one network to which you are currently connected.Aletheaalethia
@ Evan Thompson let interfaceName = interfacesArray[0] as! String this line return currently connected network SSID ThanksBackset
interfacesArray will only contain 1 element even if you are near more than 1 wi-fi access point. Thus this answers how to get details about the current network's SSID rather than all nearby network's SSIDs.Uboat
B
1

First of All import above two system Header file

import SystemConfiguration/SystemConfiguration.h
import SystemConfiguration/CaptiveNetwork.h

below Function/Method Return SSIDName

-(NSString *)getNetworkId{
    NSString *string = CFBridgingRelease(CNCopySupportedInterfaces());
    NSArray *interfacesArray = CFBridgingRelease(CFBridgingRetain(string));
        if(interfacesArray.count > 0){
            NSString *networkName = [interfacesArray objectAtIndex:0];
            CFStringRef yourFriendlyCFString = (__bridge CFStringRef)networkName;
            NSDictionary *unsafeInterfaceData = CFBridgingRelease(CNCopyCurrentNetworkInfo(yourFriendlyCFString));
            NSString *ssidName = unsafeInterfaceData[@"SSID"];
            return ssidName;
        }
    return @"No network Found";
}
Backset answered 8/3, 2017 at 9:4 Comment(3)
Only getting connected SSID,I want to fetch all ranged SSID. Can you please help me to do same ?Gidgetgie
Hi @hiteshlandge i posted another another answer in swift which given below. and that answer provide all SSID which is in range. ThanksBackset
If you clearly know this doesn't get all networks, you should kindly delete this answer since it doesn't answer what the original poster was asking.Uboat
B
0
#import SystemConfiguration#
##import SystemConfiguration.CaptiveNetwork##

 //create variable
  var SSIDNameArray = NSMutableArray()
  var nameArray : NSArray = [];
 // Here function to return all SSIDName
    func getUsedSSID()->NSArray{
        let interfaces = CNCopySupportedInterfaces()
        if interfaces != nil {
            let interfacesArray = CFBridgingRetain(interfaces) as! NSArray
            if interfacesArray.count > 0 {
                for interfaceName in interfacesArray {
                    let unsafeInterfaceData = CNCopyCurrentNetworkInfo(interfaceName as! CFString)! as NSDictionary
                    let SSIDName = unsafeInterfaceData["SSID"] as! String
                    self.SSIDNameArray .add(SSIDName)
                }
                nameArray = self.SSIDNameArray .copy() as! NSArray
                return nameArray;
            }else{
                 return nameArray;
            }
        }else{
            return nameArray;
        }
    }
Backset answered 1/8, 2017 at 5:36 Comment(1)
This only shows the connected network's SSID, not all that are in rangeUboat

© 2022 - 2024 — McMap. All rights reserved.