Get SSID (wifi name) with Swift iOS (IOS 13)
The first one, we need to enable the Access WiFi Information capability in Xcode
With iOS < 13, we can use CNCopyCurrentNetworkInfo() .
import SystemConfiguration.CaptiveNetwork
CNCopyCurrentNetworkInfo() returns nil in iOS 13 and later
Watch WWDC19 Session 713: Advances in Networking, Part 2.
Now you all know the important privacy to Apple. And one of the things we realized. Is that… Accessing Wi-Fi information can be used to infer location.
So starting now, to access that Wi-Fi information. You’ll need the same kind of privileges that you’ll need to get other location information.
Requires Capability: Access Wi-Fi Information
Must also meet at least one of criteria below
- Apps with permission to access location
- Currently enabled VPN app
- NEHotspotConfiguration (only Wi-Fi networks that the app configured)
Otherwise, returns nil
Get Wi-Fi SSID in iOS 13 and later
- Import Core Location framework
- Permission request in Info.plist
- Create Model and Variables
- Function show all wifi name
- Ask location permission
- Implement CLLocationManagerDelegate