CNCopyCurrentNetworkInfo with iOS 13

后端 未结 10 2038
攒了一身酷
攒了一身酷 2020-12-10 00:56

Apple changed some things regarding WiFi with iOS 13. If you want to use CNCopyCurrentNetworkInfo your app needs to have one of the following

  • Apps with permiss
10条回答
  •  清歌不尽
    2020-12-10 01:48

    I've spent hours trying to figure out a way to let CNCopyCurrentNetworkInfo works on iOS 13 with no results, no matter location permissions status or the fact that my app configured the current Wi-Fi network the device is currently using via NEHotspotConfiguration. It just does not work.

    I finally came out with the reliable solution to get the SSID through getConfiguredSSIDsWithCompletionHandler: method of NEHotspotConfigurationManager.

    Here's a simple example:

    static func retrieveCurrentSSID(  callback: @escaping ( String? ) -> Void ){
        NEHotspotConfigurationManager.shared.getConfiguredSSIDs { ( networkSSIDs ) in
            callback( networkSSIDs.first )
        }
    }
    
    

提交回复
热议问题