{"id":26212362,"url":"https://github.com/hackinggate/ios13-wifi-info","last_synced_at":"2025-04-15T15:22:14.366Z","repository":{"id":98541988,"uuid":"191522931","full_name":"HackingGate/iOS13-WiFi-Info","owner":"HackingGate","description":"Fix CNCopyCurrentNetworkInfo() does NOT work on iOS13","archived":false,"fork":false,"pushed_at":"2019-08-29T13:45:30.000Z","size":462,"stargazers_count":84,"open_issues_count":3,"forks_count":9,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-28T21:51:08.972Z","etag":null,"topics":["ios13","wwdc19"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HackingGate.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-12T07:44:09.000Z","updated_at":"2024-06-23T00:42:05.000Z","dependencies_parsed_at":"2023-03-13T21:00:11.240Z","dependency_job_id":null,"html_url":"https://github.com/HackingGate/iOS13-WiFi-Info","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HackingGate%2FiOS13-WiFi-Info","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HackingGate%2FiOS13-WiFi-Info/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HackingGate%2FiOS13-WiFi-Info/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HackingGate%2FiOS13-WiFi-Info/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HackingGate","download_url":"https://codeload.github.com/HackingGate/iOS13-WiFi-Info/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249095197,"owners_count":21211880,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios13","wwdc19"],"created_at":"2025-03-12T08:30:05.526Z","updated_at":"2025-04-15T15:22:14.356Z","avatar_url":"https://github.com/HackingGate.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# iOS13-WiFi-Info\nFix CNCopyCurrentNetworkInfo() does NOT work in iOS13 and later\n\n## Get Wi-Fi SSID in iOS 12 and earlier\n\n[stackoverflow](https://stackoverflow.com/a/37856496/4063462)\n\n```swift\nimport Foundation\nimport SystemConfiguration.CaptiveNetwork\n\nfunc getSSID() -\u003e String? {\n    var ssid: String?\n    if let interfaces = CNCopySupportedInterfaces() as NSArray? {\n        for interface in interfaces {\n            if let interfaceInfo = CNCopyCurrentNetworkInfo(interface as! CFString) as NSDictionary? {\n                ssid = interfaceInfo[kCNNetworkInfoKeySSID as String] as? String\n                break\n            }\n        }\n    }\n    return ssid\n}\n```\n\n\u003eTo use `CNCopyCurrentNetworkInfo()` in iOS 12 and later, enable the Access WiFi Information capability in Xcode. For more information, see [Access WiFi Information Entitlement](https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_networking_wifi-info).\n\n## CNCopyCurrentNetworkInfo() returns nil in iOS 13 and later\n\nWatch WWDC19 Session 713: [Advances in Networking, Part 2](https://developer.apple.com/videos/play/wwdc2019/713/).\n\n\u003eNow 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.\n\n\u003eSo 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.\n\n![WWDC19-CNCopyCurrentNetworkInfo().png](/screenshots/WWDC19-CNCopyCurrentNetworkInfo().png)\n\nRequires Capability: `Access Wi-Fi Information`\n\nMust also meet at least one of criteria below\n\n* Apps with permission to access location\n* Currently enabled VPN app\n* NEHotspotConfiguration (only Wi-Fi networks that the app configured)\n\nOtherwise, returns `nil`\n\n## Get Wi-Fi SSID in iOS 13 and later\n\nImport [Core Location](https://developer.apple.com/documentation/corelocation) framework\n\n```swift\nimport CoreLocation\n```\n\nFunction to update UI\n\n```swift\nfunc updateWiFi() {\n    print(\"SSID: \\(currentNetworkInfos?.first?.ssid)\")\n    ssidLabel.text = getSSID()\n}\n```\n\nAsk location permission\n\n```swift\nif #available(iOS 13.0, *) {\n    let status = CLLocationManager.authorizationStatus()\n    if status == .authorizedWhenInUse {\n        updateWiFi()\n    } else {\n        locationManager.delegate = self\n        locationManager.requestWhenInUseAuthorization()\n    }\n} else {\n    updateWiFi()\n}\n```\n\nImplement [CLLocationManagerDelegate](https://developer.apple.com/documentation/corelocation/cllocationmanagerdelegate)\n\n```swift\nclass ViewController: UIViewController, CLLocationManagerDelegate {\n    ...\n    func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {\n        if status == .authorizedWhenInUse {\n            updateWiFi()\n        }\n    }\n    ...\n}\n```\n\n## Update your app\n\nIf your app uses `CNCopyCurrentNetworkInfo()` and needs to solve the issue. Solve it now. There's no need to wait for Xcode 11 GM. The solution above is Xcode 10 compatible.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackinggate%2Fios13-wifi-info","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhackinggate%2Fios13-wifi-info","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackinggate%2Fios13-wifi-info/lists"}