MAC Address of router

WiFeedWiFeed ILMember ✭✭
edited April 2017 in Xamarin.iOS

Hello.
I want to get the MAC Address of the connected WiFi router.
How can i do this on IOS Project?
In android i scanned the arp file and got the MAC Add. of my router.
How can i do this on Xamarin.IOS or even in a different way?
Thank you.

Tagged:

Posts

  • DannyCDannyC US ✭✭✭✭

    This is what I use in iOS 9/10.

    public static string GetSSID(bool withMacAddress = true)
    {
        try {       
            NSDictionary dict;
            var status = CaptiveNetwork.TryCopyCurrentNetworkInfo ("en0", out dict);
    
            if (status == StatusCode.NoKey || dict == null)
                return "";
    
            var bssid = dict [CaptiveNetwork.NetworkInfoKeyBSSID];
            var ssid = dict [CaptiveNetwork.NetworkInfoKeySSID];
            
            if (withMacAddress)
                return string.Format ("{0} [{1}]", ssid, bssid);
            else
                return ssid.ToString ();
        } catch {
            return "";  
        }
    }
  • WiFeedWiFeed ILMember ✭✭

    @DannyC said:
    This is what I use in iOS 9/10.

    public static string GetSSID(bool withMacAddress = true)
    > {
    >   try {       
    >       NSDictionary dict;
    >       var status = CaptiveNetwork.TryCopyCurrentNetworkInfo ("en0", out dict);
    > 
    >       if (status == StatusCode.NoKey || dict == null)
    >           return "";
    > 
    >       var bssid = dict [CaptiveNetwork.NetworkInfoKeyBSSID];
    >       var ssid = dict [CaptiveNetwork.NetworkInfoKeySSID];
    >       
    >       if (withMacAddress)
    >           return string.Format ("{0} [{1}]", ssid, bssid);
    >       else
    >           return ssid.ToString ();
    >   } catch {
    >       return "";  
    >   }
    > }

    thank you for your reply.
    but i wish to find the MAC address of the router. not the ssid.
    thank you.

  • DannyCDannyC US ✭✭✭✭

    Did you even bother looking at the code? BSSID is what you are looking for.

Sign In or Register to comment.