Can I programmatically get the MAC address of wifi which is connected to my phone?

后端 未结 1 903
轮回少年
轮回少年 2021-01-17 09:34

My phone is connected to wifi.I want to get mac address of my wifi.

相关标签:
1条回答
  • 2021-01-17 10:01

    BSSID and mac address is same thing. You can get mac address from this function. just import SystemConfiguration.CaptiveNetwork

    func getWIFIInformation() -> [String:String]{
        var informationDictionary = [String:String]()
        let informationArray:NSArray? = CNCopySupportedInterfaces()
        if let information = informationArray {
            let dict:NSDictionary? = CNCopyCurrentNetworkInfo(information[0] as! CFStringRef)
            if let temp = dict {
                informationDictionary["SSID"] = String(temp["SSID"]!)
                informationDictionary["BSSID"] = String(temp["BSSID"]!)
                return informationDictionary
            }
        }
    
        return informationDictionary
    }
    
    0 讨论(0)
提交回复
热议问题