I am working an ionic project based on IOT. I need to fetch the details (WiFi name and password ) of connected WiFi in my app.I have used this plugin.
cordova plugin add cordova-plugin-network-information
But this plugin doesn't give much information like name and password of connected WiFi.Is there any plugins or methods for fetching the connected wifi details? Thanks
I don't know if this helps you, but I use the cordova plugins: wifiwizard & cordova-plugin-networkinterface to fetch network information. On iOS it is only possible to get SSID, BSSID, IP, Subnet of connected WiFi & mobile IP, because Apple's Wifi library (Apple80211) is private.
I also use cordova plugins: cordova-plugin-x-toast & cordova-plugin-dialogs for error messages.
The following method readNetwork() stores all network information to $scope.wifi:
// read network
function readNetwork() {
$scope.wifi = {};
// get current SSID
WifiWizard.getCurrentSSID(
function(ssid) {
$scope.wifi.ssid = ssid.replace('"','').replace('"','');
// update scope values in template
$scope.$apply();
},
wifiError
);
// get current BSSID - ios only
if(ionic.Platform.isIOS()) {
WifiWizard.getCurrentBSSID(
function(bssid) {
$scope.wifi.bssid = bssid;
// update scope values in template
$scope.$apply();
},
wifiError
);
}
// get list of the available networks as an array of objects - android only
if(ionic.Platform.isAndroid()) {
WifiWizard.getScanResults(
function(networks) {
$scope.wifi.networks = networks;
//console.log("networks: " + JSON.stringify(networks));
// find current bssid, if not available
networks.forEach(function(network) {
if(network.SSID == $scope.wifi.ssid) {
$scope.wifi.bssid = network.BSSID;
$scope.wifi.level = network.level;
$scope.wifi.frequency = network.frequency;
$scope.wifi.config = network.capabilities;
}
});
// update scope values in template
$scope.$apply();
},
wifiError
);
}
// get device's ip adress
networkinterface.getWiFiIPAddress(
function(ip, subnet) {
$scope.wifi.ip = ip;
$scope.wifi.subnet= subnet;
// update scope values in template
$scope.$apply();
},
function(error) {
$cordovaToast.show("WiFi IP Adresse konnte nicht ermittelt werden: " + error, "long", "center");
$cordovaDialogs.beep(1);
}
);
// get device's carrier ip adress
networkinterface.getCarrierIPAddress(function (ip) {
$scope.wifi.vendorIp = ip;
// update scope values in template
$scope.$apply();
});
}
// read network (wifi) - error
function wifiError(error) {
$cordovaToast.show("WiFi Fehler: " + error, "long", "center");
$cordovaDialogs.beep(1);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With