Iphone 单触式WIFI SSID

Iphone 单触式WIFI SSID,iphone,ios,xamarin.ios,ssid,captivenetwork,Iphone,Ios,Xamarin.ios,Ssid,Captivenetwork,是否有可能在IPhone上使用Monotouch连接WIFI SSID 我已经找到了检查Wi-Fi状态的可能性,但是没有办法检查SSID。 有人知道路吗? 感谢所有评论您可以像@Jason链接到的示例代码一样执行此操作。但目前MonoTouch的当前版本中没有针对CaptiveNet工作的绑定(但它将包含在未来的测试版中) 同时,您可以在应用程序中复制粘贴以下代码以获取SSID using System; using System.Runtime.InteropServices;

是否有可能在IPhone上使用Monotouch连接WIFI SSID

我已经找到了检查Wi-Fi状态的可能性,但是没有办法检查SSID。 有人知道路吗?
感谢所有评论

您可以像@Jason链接到的示例代码一样执行此操作。但目前MonoTouch的当前版本中没有针对CaptiveNet工作的绑定(但它将包含在未来的测试版中)

同时,您可以在应用程序中复制粘贴以下代码以获取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+版本包括对
CaptiveNet工作的支持
。上述代码简化为:

using MonoTouch.SystemConfiguration;

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

下面是一个[使用Obj-C的示例][1]。您应该能够在MT[1]中使用类似的方法:在MT 6.0.6中,CopyCurrentNetworkInfo现已过时。请改用TryCopyCurrentNetworkInfo。