MonoTouch WIFI SSID

是否有可能使用Monotouch连接iPhone的连接WIFI SSID?

我发现有可能检查Wi-Fi状态,但是没有办法检查SSID。 https://github.com/xamarin/monotouch-samples/blob/master/ReachabilitySample/reachability.cs所以有没有人知道一种方式? 感谢所有评论

你可以像@Jason链接的示例代码那样做。 但现在,在当前版本的MonoTouch中没有对CaptiveNetwork的绑定(但它将包含在未来的beta版本中)。

在此期间,您可以将以下代码复制粘贴到应用程序中以获取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); } } 

更新 :最新的MonoTouch 5.2+版本包括对CaptiveNetwork支持。 上面的代码被简化为:

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