Is it possible to get the name of the Wifi network one is connected to in Xojo?
Reason: iPad app and Desktop app need to connect. Won't work if they're not on the same network.
For macOS, see this thread. A reply in that thread also mentions using WMI under Windows, but does not include sample code.
For iOS, I used to use code to get this in non-Xojo apps, but more recent OS versions blocked it...
@Bob G Reason: iPad app and Desktop app need to connect. Won't work if they're not on the same network.
And the SSID won't necessarily answer this either. You could have multiple SSID's that can connect to each other, and you can have an SSID that is the same but intraLan connections are blocked. (As is or should be typical of public Wifi such as hotels, venues, coffee shops, etc)
@Dave S don't you just need to make sure the first 3 triplets of the IP address match?
That would only determine if on the same subnet if the subnet mask was 255.255.255.0 -- and while that is true in many cases, it is not necessarily true. But even if you consider the subnet -- or the SSID name -- that does not necessarily mean they can communicate.
I have used obj-C code to get the SSID name to show in an About box, along with the device IP and the public IP, but just as an aid in tech support. And then iOS started blocking access to the SSID name ...
I had a quick gander at my old code: Turns out for both OS's I just drop to a shell and use built in tools.
On OS X, you can use this command to see the currently connected WiFi network:
(run it without the -I for lots more info)
On Windows, I use
Again, you'll want to play with this command to get it to show you exactly what you are looking for. From within Xojo, start up a shell, run the command for the OS you are on, and parse the results from the shell object.
@Bob G — After some researches, for my own curiosity, it seems that the common current ways are:
On macOS: use the CWInterface object which allows you to get the SSID but also to scan networks for a given SSID (from 10.6)
On iOS: the current way is to use the NEHotspotHelper object to get the SSID (from iOS 9)