How do I use CaptiveNetwork to get the current WiFi Hotspot Name

后端 未结 4 2051
迷失自我
迷失自我 2020-11-28 04:17

I need to get the name of the currently connected Wi-Fi hotspot, e.g. \"BT OpenZone\"

I have been told it can be done with CaptiveNetwork specifically CNCopyCurrentN

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-28 05:10

    You need to find out which networks are available, and then pass them into CNCopyCurrentNetworkInfo. For example:

    CFArrayRef myArray = CNCopySupportedInterfaces();
    CFDictionaryRef myDict = CNCopyCurrentNetworkInfo(CFArrayGetValueAtIndex(myArray, 0));
    

    ...and you can then use the kCNNetworkInfoKeySSID on the dictionary you've got back (myDict) to find out the SSID. Don't forget to release/manage memory appropriately.

提交回复
热议问题