From 6a3b2f18e6fb060911e80f3c2a860524fdb23919 Mon Sep 17 00:00:00 2001 From: Sebastian Grodzicki Date: Mon, 8 May 2023 15:49:52 +0200 Subject: [PATCH] Add `isHidden` to `secureConnect` --- .../plugin_wifi_connect/PluginWifiConnectPlugin.kt | 4 ++++ ios/Classes/SwiftPluginWifiConnectPlugin.swift | 1 + lib/plugin_wifi_connect.dart | 4 +++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/android/src/main/kotlin/com/peakysoftware/plugin_wifi_connect/PluginWifiConnectPlugin.kt b/android/src/main/kotlin/com/peakysoftware/plugin_wifi_connect/PluginWifiConnectPlugin.kt index 3f4eb65..6e098b1 100644 --- a/android/src/main/kotlin/com/peakysoftware/plugin_wifi_connect/PluginWifiConnectPlugin.kt +++ b/android/src/main/kotlin/com/peakysoftware/plugin_wifi_connect/PluginWifiConnectPlugin.kt @@ -117,6 +117,7 @@ class PluginWifiConnectPlugin() : FlutterPlugin, MethodCallHandler { val password = call.argument("password") val isWep = call.argument("isWep") val isWpa3 = call.argument("isWpa3") + val isHidden = call.argument("isHidden") if (ssid == null || password == null || isWep == null) { return @@ -141,6 +142,9 @@ class PluginWifiConnectPlugin() : FlutterPlugin, MethodCallHandler { } else { setWpa2Passphrase(password) } + if (isHidden) { + setIsHiddenSsid(true) + } } .build() connect(specifier, result) diff --git a/ios/Classes/SwiftPluginWifiConnectPlugin.swift b/ios/Classes/SwiftPluginWifiConnectPlugin.swift index 2369b77..5b20df4 100644 --- a/ios/Classes/SwiftPluginWifiConnectPlugin.swift +++ b/ios/Classes/SwiftPluginWifiConnectPlugin.swift @@ -43,6 +43,7 @@ public class SwiftPluginWifiConnectPlugin: NSObject, FlutterPlugin { let args = try GetArgs(arguments: call.arguments) let hotspotConfig = NEHotspotConfiguration.init(ssid: args["ssid"] as! String, passphrase: args["password"] as! String, isWEP: args["isWep"] as! Bool) hotspotConfig.joinOnce = !(args["saveNetwork"] as! Bool); + hotspotConfig.isHidden = args["isHidden"] as! Bool; connect(hotspotConfig: hotspotConfig, result: result) return diff --git a/lib/plugin_wifi_connect.dart b/lib/plugin_wifi_connect.dart index ba3db09..81e7e81 100644 --- a/lib/plugin_wifi_connect.dart +++ b/lib/plugin_wifi_connect.dart @@ -59,7 +59,8 @@ class PluginWifiConnect { static Future connectToSecureNetwork(String ssid, String password, {bool isWep = false, bool isWpa3 = false, - bool saveNetwork = false}) async { + bool saveNetwork = false, + bool isHidden = false}) async { final bool? connected = await _channel.invokeMethod( 'secureConnect', { @@ -68,6 +69,7 @@ class PluginWifiConnect { 'saveNetwork': saveNetwork, 'isWep': isWep, 'isWpa3': isWpa3, + 'isHidden': isHidden, }, ); return connected;