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

fix(wifi_iot): iOS isConnected always true even connection is failed - synced with master #407

Merged
Merged
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
21 changes: 7 additions & 14 deletions packages/wifi_iot/ios/Classes/SwiftWifiIotPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,7 @@ public class SwiftWifiIotPlugin: NSObject, FlutterPlugin {
let sPassword = (call.arguments as? [String : AnyObject])?["password"] as? String? ?? nil
let bJoinOnce = (call.arguments as? [String : AnyObject])?["join_once"] as! Bool?
let sSecurity = (call.arguments as? [String : AnyObject])?["security"] as! String?

// print("SSID : '\(sSSID)'")
// print("PASSWORD : '\(sPassword)'")
// print("JOIN_ONCE : '\(bJoinOnce)'")
// if (bJoinOnce) {
// print("The network will be forgotten!")
// }
// print("SECURITY : '\(sSecurity)'")

if #available(iOS 11.0, *) {
let configuration = initHotspotConfiguration(ssid: sSSID, passphrase: sPassword, security: sSecurity)
configuration.joinOnce = bJoinOnce ?? false
Expand All @@ -142,19 +135,19 @@ public class SwiftWifiIotPlugin: NSObject, FlutterPlugin {
result(false)
return
}
this.getSSID { (sSSID) -> () in
this.getSSID { (connectedSSID) -> () in
if (error != nil) {
if (error?.localizedDescription == "already associated.") {
print("Connected to '\(sSSID ?? "<Unknown Network>")'")
print("Connected to '\(connectedSSID ?? "<Unknown Network>")'")
result(true)
} else {
print("Not Connected")
result(false)
}
} else if let ssid = sSSID {
print("Connected to " + ssid)
// ssid check is required because if wifi not found (could not connect) there seems to be no error given
result(ssid == sSSID)
} else if let connectedSSID = connectedSSID {
print("Connected to " + connectedSSID)
// Emit result of [isConnected] by checking if targetSSID is the same as connectedSSID.
result(sSSID == connectedSSID)
} else {
print("WiFi network not found")
result(false)
Expand Down
Loading