iOS Question Get Wifi SSID

Andrea Falcucci

Member
Licensed User
Longtime User
Hi guys.

I'm facing something that it seems to be a common problem with iOS13 : get wifi SSID.

Until iOS13, everything worked like a charm....
B4X:
ssid = NativeMe.RunMethod("currentWifiSSID", Null).AsString
and
B4X:
#If OBJC

#import <SystemConfiguration/CaptiveNetwork.h>

- (NSString *)currentWifiSSID {
  // Does not work on the simulator.
  NSString *ssid = nil;
  NSArray *ifs = (__bridge_transfer id)CNCopySupportedInterfaces();
  for (NSString *ifnam in ifs) {
  NSDictionary *info = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam);
  if (info[@"SSID"]) {
  ssid = info[@"SSID"];
  }
  }
  return ssid;
}
#end if
Tried enabling Wifi Access on Identifiers and recreate provisioning file.... Nothing.

I need to check if the SSID name is related to one of our products. Any help?

Thank you
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Please use [code]code here...[/code] tags when posting code.

 
Upvote 0

Andrea Falcucci

Member
Licensed User
Longtime User

Read that but I'm unable to let the system get the wifi. The answer is always nil (it raised an error of object not initialized and catched in OBJ code).

The provisioning file has wifi and hotspot capability.

At the beginning of the procedure we get authorization with
B4X:
Locmanager.start(0)

But nothing to do.
Jumping this control and connecting to the device, even UDP packets stopped working....

In Android10 no problem at all.... As usual
 
Upvote 0

Andrea Falcucci

Member
Licensed User
Longtime User
just tested on iPad with iOS 9.3 -> perfect.
Installed on iPhone with iOS 13.3 -> nothing works (related to wifi and UDP communication).

At apple someone has the idea of the useless work all the developer have to do for their weird ideas???

Not considering the annual fee to be on the app store....

Very very angry.
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
Actually "currentWifiSSID" works under 13.3 (at least on my iPhone 6s).

1) https://developer.apple.com/
Open your identifier and enable 'Access WiFi Information' . Re-issue your .mobileprovision

2) In project attributes add
B4X:
    #Entitlement        : <key>com.apple.developer.networking.wifi-info</key><true/>
    #PlistExtra         : <key>NSLocationWhenInUseUsageDescription</key><string>Used to display the current navigation data.</string>
    #PlistExtra         : <key>NSLocationUsageDescription</key><string>Used to display the current navigation data.</string>

3) Inside your program, first of all, initialize LocationManager and wait, for example, LocationChanged event. Then call "currentWifiSSID" subroutine
 
Upvote 0

Andrea Falcucci

Member
Licensed User
Longtime User


You are the man... The key was to wait the location event.

Thank you so much!!!!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…