CNCopyCurrentNetworkInfo with iOS 13

后端 未结 10 1997
攒了一身酷
攒了一身酷 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

    As I said on the Apple Developer Forums use of CNCopyCurrentNetworkInfo is now limited.

    Check out WWDC 19 session 713, Advances in Networking, Part 2 (maybe 75% of the way through the presentation). CNCopyCurrentNetworkInfo is now only available to your app in three cases:

    • Apps with permission to access location
    • Your app is the currently enabled VPN app
    • Your app configured the WiFi network the device is currently using via NEHotspotConfiguration

    If you don't meet at least one of these conditions CNCopyCurrentNetworkInfo will always return nil in iOS 13.

    UPDATE: As of iOS 13 Developer Beta 6, Apple has finally updated the documentation to note the changes.

    0 讨论(0)
  • 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 )
        }
    }
    
    
    0 讨论(0)
  • 2020-12-10 01:51

    Must verify that

    <key>com.apple.developer.networking.wifi-info</key>
    <true/>
    

    is added to Entitlements-Release.plist, mostly its just added to Entitlements-Debug.plist only

    0 讨论(0)
  • 2020-12-10 01:52

    I believe that you match one of the following condition which is suggested by Apple:

    1 :Apps with permission to access location

    2 :Your app is the currently enabled VPN app

    3 :Your app configured the WiFi network the device is currently using via NEHotspotConfiguration

    In my case even i have location services enable when was facing the issue.

    After some workaround here are i found the two solution which you can try:

    1: Reboot the device. This works for me!!.

    2: Update the OS if available.

    I am not sure it helps you but in few cases it should work, few people suggest reboot 2-3 times work for them.

    Another good news from Apple that they fix for this issue on iOS 13.3 beta version

    0 讨论(0)
提交回复
热议问题