CNCopyCurrentNetworkInfo with iOS 13 fails on fetching SSID name from connected WiFi network, detectSSIDChange() method fails to call purgeDeviceList() in DiscoveryManager
Opened this issue · 0 comments
Starting with iOS 14, the SSID of the currently connected Wi-Fi network can be obtained using the fetchCurrent(completionHandler:) method of the NEHotspotNetwork class. Note that the use of fetchCurrent(completionHandler:) does not require the NEHotspotHelper entitlement.
This method returns SSID of the current connected Wi-Fi network when the requesting application meets one of following 4 requirements:
• Application is using CoreLocation API and has user's authorization to access precise location.
• Application has used NEHotspotConfiguration API to configure the current Wi-Fi network.
• Application has active VPN configurations installed.
• Application has active NEDNSSettingsManager configuration installed.
An application will receive nil if it fails to meet any of the above 4 requirements.
An application will receive nil if does not have the “Access WiFi Information” (“com.apple.developer.networking.wifi-info”) capability in your entitlement.
In iOS 13 and in previous versions, the official document of CNCopyCurrentNetworkInfo says that the function is providing real SSID/BSSID of current connection of WiFi, if the app:
• has an "Access WiFi Information Entitlement" and
One of the following should meet:
• Apps with permission to access location
• App is the currently enabled VPN app
• App configured the WiFi network the device is currently using via NEHotspotConfiguration
If you don't meet at least one among above 3 conditions CNCopyCurrentNetworkInfo will always return nil in iOS 13 and in previous versions.
Due to above issue, the method detectSSIDChange() from DiscoveryManager.m fails to fetch SSID and sets _currentSSID = nil always. So the method purgeDeviceList() will not called while app's connected wifi is disabled and then enabled to establish connection again. ConnectableDevice object device.lastSeenOnWifi = nil always which fails to purge device list.
To solve this issue, we applied the above changes (Added CoreLocation framework and asked user to access current location, by adding Access WiFi Information to entitlement) in ConnectSDK framework using in our app development. Issue has been resolved.
Resources:
https://developer.apple.com/forums/thread/117371
https://developer.apple.com/documentation/systemconfiguration/1614126-cncopycurrentnetworkinfo?language=objc
https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_networking_wifi-info?language=objc
https://developer.apple.com/videos/play/wwdc2019/713/
https://developer.apple.com/forums/thread/679038