CNCopyCurrentNetworkInfo with iOS 13

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

    Starting with iOS 13, the CNCopyCurrentNetworkInfo API will no longer return valid Wi-Fi SSID and BSSID information. Instead, the information returned by default will be:

    SSID: “Wi-Fi” or “WLAN” (“WLAN" will be returned for the China SKU) BSSID: "00:00:00:00:00:00"

    If your app is using this API, Apple now encourage you to adopt alternative approaches that don’t require Wi-Fi or network information. Valid SSID and BSSID information from CNCopyCurrentNetworkInfo will still be provided to VPN apps, apps that have used NEHotspotConfiguration to configure the current Wi-Fi network, and apps that have obtained permission to access user location through Location Services.

    You can Test your app on the latest iOS 13 beta to make sure it works properly. If your app requires valid Wi-Fi SSID and BSSID information to function, you can do the following: For accessory setup apps, use the NEHotSpotConfiguration API, which now has the option to pass a prefix of the SSID hotspot your app expects to connect to. For other types of apps, use the CoreLocation API to request the user’s consent to access location information.

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

    I had same issue from iOS 13.0 but it seems that apple fixed in 13.3 The requirement in the doc that it should be either a network added by the app or that location should be enabled or that app had an active VPN did not work for 13.1 13.1 13.2

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

    If someone tries to use CNCopyCurrentNetworkInfo via the case Apps with permission to access location (via the CoreLocation API and CLLocationManager) don't forget to enable the Access WiFi Information capability (See also this answer here). This should be mandatory since iOS 12, but I needed to update an App which was last tested before iOS 12. See also from the Discussion Section here:

    Important

    To use this function, an app linked against iOS 12 or later must enable the Access WiFi Information capability in Xcode. For more information, see Access WiFi Information Entitlement. Calling this function without the entitlement always returns NULL when linked against iOS 12 or later.

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

    I have a similar issue in my app. I have submitted a feedback form to Apple and got a response stating:

    Potential fix identified - For a future OS update

    So hopefully, this will be resolved before the final release (not in iOS 13 Beta 4 though).

    For a workaround, you can set joinOnce = false in your NEHotspotConfiguration. In my app, it allowed me to access CNCopySupportedInterfaces, but required me to remove configuration every time my app was closed.

    Hope it helps!

    Edit:

    It seems that in iOS 13 beta 5 issue no longer persists. In my application, I can access CNCopyCurrentNetworkInfo again (thus confirming the Wi-Fi has been connected), no matter if NEHotspotConfiguration.joinOnce flag is set to true or false.

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

    Seems silly, but in some cases one must reboot to get this to work properly even though this worked fine before the in case the iOS 13 beta update.

    see also at: https://forums.developer.apple.com/thread/123244

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

    For me, TryCopyCurrentNetworkInfo always return nil even with a network configured with NEHotspotConfiguration. I tried the the recommendation of Mateusz with setting the option JoinOne to false or true but it did not solve the issue.

    Phone OS is 13.1.3 Access WiFi information is enabled in my profile It was working in iOS 12

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