#import <SystemConfiguration/CaptiveNetwork.h>
/**
獲取wifi無線ap的mac地址
- returns: <#return value description#>
*/
func getMAC()->(success:Bool,ssid:String,mac:String){
if let cfa:NSArray = CNCopySupportedInterfaces() {
for x in cfa {
if let dict = CFBridgingRetain(CNCopyCurrentNetworkInfo(x as! CFString)) {
let ssid = dict["SSID"]!
let mac = dict["BSSID"]!
return (true,ssid as! String,mac as! String)
}
}
}
return (false,"","")
}
'CNCopySupportedInterfaces()' was deprecated in iOS 9.0:
For captive network applications,
this has been completely replaced by <NetworkExtension/NEHotspotHelper.h>.
For other applications,
there is no direct replacement.
Please file a bug describing your use of this API to that we can consider your requirements as this situation evolves.
'CNCopyCurrentNetworkInfo' was deprecated in iOS 9.0:
For captive network applications,
this has been completely replaced by <NetworkExtension/NEHotspotHelper.h>.
For other applications,
there is no direct replacement.
Please file a bug describing your use of this API to that we can consider your requirements as this situation evolves.
/**
獲取唯一標(biāo)識(shí)
- returns: <#return value description#>
*/
func getIdentifierForVendor() -> String?{
return UIDevice.currentDevice().identifierForVendor?.UUIDString
}
調(diào)用示例:
let wifo = getMAC()
let deviceFlag = getIdentifierForVendor()
let wifiName = wifo.ssid
let wifiMac = wifo.mac
let UUID = deviceFlag!
print("wifiName:" + wifiName)
print("wifiMac:" + wifiMac)
print("UUID:" + UUID)
UUID&UDID
UUID(Universally Unique Identifier)
:2F426030-0A6C-4012-9259-59E533D2E970
UUID是Universally Unique Identifier的縮寫,中文意思是通用唯一識(shí)別碼.
UDID(Unique Device Identifier)
:c71a503fd518f8ddc6aedf5842f019d7eaf8eb11
UDID是Unique Device Identifier的縮寫,中文意思是設(shè)備唯一標(biāo)識(shí).