iOS Question Is there a way to get all available WiFi network in range in i OS?

Erel

B4X founder
Staff member
Licensed User
Longtime User
Here:
B4X:
Private Sub Application_Start (Nav As NavigationController)
   NavControl = Nav
   Page1.Initialize("Page1")
   Page1.RootPanel.LoadLayout("1")
   Nav.ShowPage(Page1)
   Dim no As NativeObject = Me
   Dim ssids As List = no.RunMethod("getSSIDs", Null)
   Log(ssids)
End Sub

#If OBJC
#import <SystemConfiguration/CaptiveNetwork.h>
- (NSMutableArray*)getSSIDs {
   NSMutableArray* res = [NSMutableArray new];
  NSArray *ifs = (__bridge_transfer id)CNCopySupportedInterfaces();
  for (NSString *ifnam in ifs) {
  NSDictionary *info = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);
  if (info[@"SSID"]) {
       B4IMap* map = [B4IMap new];
       map.dict = info;
       [res addObject:map];
  }
  }
   return res;
}

#End If

It will return a list of maps. Each map holds the information of a network.
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
As far as I know, in iOS, it is not possible to scan a network and obtain information of available access-points. You can only get information from the access-point your device is connected to.

I'd love to be corrected since this is a feature I'd love to see implemented.
 
Upvote 0

hanyelmehy

Active Member
Licensed User
Longtime User
Here:
B4X:
Private Sub Application_Start (Nav As NavigationController)
   NavControl = Nav
   Page1.Initialize("Page1")
   Page1.RootPanel.LoadLayout("1")
   Nav.ShowPage(Page1)
   Dim no As NativeObject = Me
   Dim ssids As List = no.RunMethod("getSSIDs", Null)
   Log(ssids)
End Sub

#If OBJC
#import <SystemConfiguration/CaptiveNetwork.h>
- (NSMutableArray*)getSSIDs {
   NSMutableArray* res = [NSMutableArray new];
  NSArray *ifs = (__bridge_transfer id)CNCopySupportedInterfaces();
  for (NSString *ifnam in ifs) {
  NSDictionary *info = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);
  if (info[@"SSID"]) {
       B4IMap* map = [B4IMap new];
       map.dict = info;
       [res addObject:map];
  }
  }
   return res;
}

#End If

It will return a list of maps. Each map holds the information of a network.
Thank you i well try this
 
Upvote 0

touchsquid

Active Member
Licensed User
Longtime User
I tried this. It works but only returns the connected network, although there are 4 or 5 others in range.
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
That is what I wrote in my previous post. It's a limitation of iOS.
 
Upvote 0

b4xscripter

Member
Licensed User
Longtime User
So, no way to detect a "unknown" wifi? I don't mean the mac address, I only mean the public wifi name. That is a bit strange as from Iphone / Ipad we can always see the available (visible) wifi hotspots when we try to connect to.

Regards
 
Upvote 0

tmf

Member
Licensed User
Longtime User
I see this is an old thread, but wanted to know if you can connect to a known AP, so proprietorially can you say connect to "X" if you know X is there....
 
Upvote 0
Top