Created
November 8, 2013 14:30
-
-
Save dannycabrera/7371787 to your computer and use it in GitHub Desktop.
Xamarin.iOS GetSSID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string GetSSID(bool withMacAddress = true) | |
{ | |
try { | |
NSDictionary dict; | |
var status = CaptiveNetwork.TryCopyCurrentNetworkInfo ("en0", out dict); | |
if (status == StatusCode.NoKey) | |
return ""; | |
var bssid = dict [CaptiveNetwork.NetworkInfoKeyBSSID]; | |
var ssid = dict [CaptiveNetwork.NetworkInfoKeySSID]; | |
//var ssiddat = dict [CaptiveNetwork.NetworkInfoKeySSIDData]; | |
if (withMacAddress) | |
return string.Format ("{0} [{1}]", ssid, bssid); | |
else | |
return ssid.ToString (); | |
/* | |
foreach (string intf in CaptiveNetwork.GetSupportedInterfaces()) { | |
NSDictionary dict2; | |
CaptiveNetwork.TryCopyCurrentNetworkInfo (intf, out dict2); | |
//if (status == StatusCode.NoKey) | |
// return ""; | |
var bssid2 = dict [CaptiveNetwork.NetworkInfoKeyBSSID]; | |
var ssid2 = dict [CaptiveNetwork.NetworkInfoKeySSID]; | |
var ssiddat2 = dict [CaptiveNetwork.NetworkInfoKeySSIDData]; | |
} | |
*/ | |
} catch { | |
return ""; | |
} | |
} |
Thank you, Sheraz16 I implemented it and it worked on my project, is there a way to get the signal strength of the WIFI?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the input @sheraz16.