Licence
MIT
Version
1.0.3
Deps
0
Vulns
0
Weekly
0
cordova-plugin-wifi
Version 1.0.3
API
connectWifi: function(ssid, pass, success, error)
connectWifiOpen: function(ssid, success, error)
/* boolean */ isWifiEnabled: function(success, error)
setWifiEnabled: function(enabled, success, error)
/* boolean */ isWifiConnected: function(success, error)
/* string */ getCurrentSSID: function(success, error)
/* string */ getMacAddress: function(success, error)
/* Array<Object> */ listWifiNetworks: function(success, error)
/* Array<string> */ getConfiguredNetworks: function(success, error)
Installation
Add plugin in cordova app
cordova plugin add com.gurvanhenry.cordova-plugin-wifi
Basic Usage
var success = function(message) { alert(message); };
var error = function(message) { alert("Error"); };
Wifi.isWifiEnabled(this.success, this.error);
Wifi.setWifiEnabled(true, this.success, this.error);
Wifi.connectWifi("wifispot", "megapass", success, error);
Wifi.getMacAddress(this.success, this.error);
Check out more with this sample
https://github.com/gurvanhenry/cordova-plugin-wifi-sample
Notes
getMacAddresscomplexity- Android do not provide mac address with
WifiInfoon Android >= 6- new security rules: see API 6 changes
- see code Wifi.java getMacAddress_sol1()
- the result will be "020000:00"
- This plugin include a workaround that use network information
- see code Wifi.java getMacAddress_sol2()
- Android 7 changed the rule again
- DevicePolicyManager can be used see API 7 changes
- this plugin do not handle that case
- Android do not provide mac address with
listWifiNetworkspermission issue- Since Android 6 (again)
ACCESS_COARSE_LOCATIONlocation permission as to be asked on runtime (popup)
- Since Android 6 (again)