Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(ios): handle deprecation of CNCopyCurrentNetworkInfo #150

Merged
merged 2 commits into from
Jul 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Becareful, some commands as no effect on iOS because Apple don't let us to do wh
| Registering / Unregistering a WiFi network | :white_check_mark:(5c) | :warning:(2) |
| Getting informations like : | :white_check_mark: | :warning:(3) |
| - SSID | :white_check_mark: | :white_check_mark: |
| - BSSID | :white_check_mark: | :x: |
| - BSSID | :white_check_mark: | :white_check_mark: |
| - Current signal strength | :white_check_mark: | :x: |
| - Frequency | :white_check_mark: | :x: |
| - IP | :white_check_mark: | :question:(4) |
Expand Down
32 changes: 22 additions & 10 deletions ios/Classes/SwiftWifiIotPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,17 @@ public class SwiftWifiIotPlugin: NSObject, FlutterPlugin {

private func getSSID() -> String? {
var ssid: String?
if let interfaces = CNCopySupportedInterfaces() as NSArray? {
for interface in interfaces {
if let interfaceInfo = CNCopyCurrentNetworkInfo(interface as! CFString) as NSDictionary? {
ssid = interfaceInfo[kCNNetworkInfoKeySSID as String] as? String
break
if #available(iOS 14.0, *) {
NEHotspotNetwork.fetchCurrent(completionHandler: { currentNetwork in
ssid = currentNetwork?.ssid
})
} else {
if let interfaces = CNCopySupportedInterfaces() as NSArray? {
for interface in interfaces {
if let interfaceInfo = CNCopyCurrentNetworkInfo(interface as! CFString) as NSDictionary? {
ssid = interfaceInfo[kCNNetworkInfoKeySSID as String] as? String
break
}
}
}
}
Expand All @@ -248,11 +254,17 @@ public class SwiftWifiIotPlugin: NSObject, FlutterPlugin {

private func getBSSID() -> String? {
var bssid: String?
if let interfaces = CNCopySupportedInterfaces() as NSArray? {
for interface in interfaces {
if let interfaceInfo = CNCopyCurrentNetworkInfo(interface as! CFString) as NSDictionary? {
bssid = interfaceInfo[kCNNetworkInfoKeyBSSID as String] as? String
break
if #available(iOS 14.0, *) {
NEHotspotNetwork.fetchCurrent(completionHandler: { currentNetwork in
bssid = currentNetwork?.bssid
})
} else {
if let interfaces = CNCopySupportedInterfaces() as NSArray? {
for interface in interfaces {
if let interfaceInfo = CNCopyCurrentNetworkInfo(interface as! CFString) as NSDictionary? {
bssid = interfaceInfo[kCNNetworkInfoKeyBSSID as String] as? String
break
}
}
}
}
Expand Down