MonoTouch WIFI SSID

is it possible to connect to the iPhone connected WIDI SSID using Monotouch?

I found an opportunity to check Wi-Fi status, but it is not possible to check the SSID. https://github.com/xamarin/monotouch-samples/blob/master/ReachabilitySample/reachability.cs So did anyone know the way? Thanks for all the comments.

+6
source share
1 answer

You can do this as an example of the code @Jason is associated with. But right now there are no bindings for CaptiveNetwork in current versions of MonoTouch (but it will be included in a future beta).

In the meantime, you can copy-paste the following code inside your application to get the SSID.

using System; using System.Runtime.InteropServices; using MonoTouch; using MonoTouch.CoreFoundation; using MonoTouch.Foundation; using MonoTouch.ObjCRuntime; [DllImport (Constants.SystemConfigurationLibrary)] extern static IntPtr CNCopyCurrentNetworkInfo (IntPtr interfaceName); static string GetSSID () { IntPtr scl = Dlfcn.dlopen (Constants.SystemConfigurationLibrary, 0); try { using (NSString en0 = new NSString ("en0")) { using (NSDictionary dict = new NSDictionary (CNCopyCurrentNetworkInfo (en0.Handle))) { using (NSString key = Dlfcn.GetStringConstant (scl, "kCNNetworkInfoKeySSID")) { return dict [key].ToString (); } } } } catch (EntryPointNotFoundException) { // this is not available when running on the simulator return String.Empty; } finally { Dlfcn.dlclose (scl); } } 

UPDATE . The most recent versions of MonoTouch 5.2+ include support for CaptiveNetwork . The above code is simplified:

 using MonoTouch.SystemConfiguration; static string GetSSID () { var dict = CaptiveNetwork.CopyCurrentNetworkInfo ("en0"); return dict [CaptiveNetwork.NetworkInfoKeySSID].ToString (); } 
+6
source

Source: https://habr.com/ru/post/904655/


All Articles