@@ -124,14 +124,7 @@ public class SwiftWifiIotPlugin: NSObject, FlutterPlugin {
124124 let sPassword = ( call. arguments as? [ String : AnyObject ] ) ? [ " password " ] as? String ? ?? nil
125125 let bJoinOnce = ( call. arguments as? [ String : AnyObject ] ) ? [ " join_once " ] as! Bool ?
126126 let sSecurity = ( call. arguments as? [ String : AnyObject ] ) ? [ " security " ] as! String ?
127-
128- // print("SSID : '\(sSSID)'")
129- // print("PASSWORD : '\(sPassword)'")
130- // print("JOIN_ONCE : '\(bJoinOnce)'")
131- // if (bJoinOnce) {
132- // print("The network will be forgotten!")
133- // }
134- // print("SECURITY : '\(sSecurity)'")
127+
135128 if #available( iOS 11 . 0 , * ) {
136129 let configuration = initHotspotConfiguration ( ssid: sSSID, passphrase: sPassword, security: sSecurity)
137130 configuration. joinOnce = bJoinOnce ?? false
@@ -142,19 +135,19 @@ public class SwiftWifiIotPlugin: NSObject, FlutterPlugin {
142135 result ( false )
143136 return
144137 }
145- this. getSSID { ( sSSID ) -> ( ) in
138+ this. getSSID { ( connectedSSID ) -> ( ) in
146139 if ( error != nil ) {
147140 if ( error? . localizedDescription == " already associated. " ) {
148- print ( " Connected to ' \( sSSID ?? " <Unknown Network> " ) ' " )
141+ print ( " Connected to ' \( connectedSSID ?? " <Unknown Network> " ) ' " )
149142 result ( true )
150143 } else {
151144 print ( " Not Connected " )
152145 result ( false )
153146 }
154- } else if let ssid = sSSID {
155- print ( " Connected to " + ssid )
156- // ssid check is required because if wifi not found (could not connect) there seems to be no error given
157- result ( ssid == sSSID )
147+ } else if let connectedSSID = connectedSSID {
148+ print ( " Connected to " + connectedSSID )
149+ // Emit result of [isConnected] by checking if targetSSID is the same as connectedSSID.
150+ result ( sSSID == connectedSSID )
158151 } else {
159152 print ( " WiFi network not found " )
160153 result ( false )
0 commit comments