1

I have this app which is coded in Objective C. In my app there is a scenario in which I want to list out all the available Wi-Fi networks available to connect with my iPad. When I googled it I found out the private APIs are the only one option. Is there any other way with which I can show all the available Wi-Fi networks? I found a way to show the already connected WiFi connection name and details. But I want the Wi-Fi available connection list in my App. Thanks in advance. Happy Coding.

    NSString *wifiName = nil;
NSArray *ifs = (__bridge_transfer id)CNCopySupportedInterfaces();
for (NSString *ifnam in ifs)
{

    NSDictionary *info = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);


    NSLog(@"info:%@",info);

    if (info[@"SSID"])
    {
        wifiName = info[@"SSID"];
        if(([wifiName rangeOfString:@"WA"].location == NSNotFound))
        {
            _textfield.textColor=[UIColor redColor];
            _textfield.text=@"";
            _textfield.hidden=YES;
        }
        else
        {
            _textfield.textColor=[UIColor blackColor];
            _textfield.text=wifiName;
            _textfield.hidden=NO;
ALEX
  • 11
  • 3
  • then why cant you go through with those api you found, is any problem you facing ? – vaibhav Nov 09 '16 at 11:07
  • I haven't tried it but from the internet I read that using that may cause the app to get rejected. – ALEX Nov 09 '16 at 11:09
  • i suggest you to check before you implement this kind of functionality, and your ques seems like opinion based we cant see any tried code here. – vaibhav Nov 09 '16 at 11:19

1 Answers1

0

U can list local Wifi like it's done here

Or u can refer to this question

The most interesting part is

struct ifaddrs {
    struct ifaddrs  *ifa_next;
    char        *ifa_name;
    unsigned int     ifa_flags;
    struct sockaddr *ifa_addr;
    struct sockaddr *ifa_netmask;
    struct sockaddr *ifa_dstaddr;
    void        *ifa_data;
};

where

NSString *name = [NSString stringWithUTF8String:temp_addr->ifa_name];
NSString *addr = [NSString stringWithUTF8String:inet_ntoa(((struct sockaddr_in *)temp_addr->ifa_addr)->sin_addr)]; // pdp_ip0


en0 is of type IEEE80211
en3 is of type Ethernet
en1 is of type Ethernet
en2 is of type Ethernet
bridge0 is of type Bridge
pdp_ip0 is of type cellular
utun0 is of type vpn
ipv4 is of type Ethernet
ipv6 is of type Ethernet
ap is of type accesPoint

This link and this can also be helpfull

Community
  • 1
  • 1
hbk
  • 10,908
  • 11
  • 91
  • 124