Hi. Does anyone implemented a wifi scanner? I am trying to use WifiWizard plugin, I installed and it is working, but I am having trouble with the provider I use to get the networks: This is what I have, I use some of the code :
It is done for Ionic v1 but I can’t get the provider to return the array of the scanned networks…
import { Injectable } from ‘@angular/core’;
import ‘rxjs/add/operator/map’;
import { Platform } from ‘ionic-angular’;
declare let WifiWizard: any;
let items: WifiInfo[] = [];
export class WifiInfo {
ssid: string;
constructor(ssid: string) {
this.ssid = ssid;
}
}
@Injectable()
export class Service {
currentWifi: WifiInfo;
// users: any; // if it’s a class member
constructor(private platform: Platform) {
}
public init(): WifiInfo {
this.platform.ready().then(() => {
WifiWizard.startScan(successNetwork, failNetwork);
function successNetwork(e){
WifiWizard.getScanResults(listHandler, failNetwork);
// alert(“getScanResults:”);
}
function listHandler(a){
// let network_array = [];
var users: WifiInfo[] = []; // if it's a local variable
//var users: WifiInfo; // if it's a local variable
for(var i=0; i<a.length; i++){
users.push(a[i].SSID);
//users = new WifiInfo(a[i].SSID);
//network_array.push(a[i].SSID);
//this.users.push(a[i].SSID);
}
// return users;
alert("network_array:"+ users);
//return “this.users.ssid”;
/* this.unique_array = network_array.filter(function(elem, pos) {
return network_array.indexOf(elem) == pos;
});*/
//alert(“network_array:”+network_array);
}
/* function listHandler(e){
alert("listHandler: " + e);
}*/
function failNetwork(e){
alert("Network Failure: " + e);
}
});
return this.currentWifi;
}
public getWifiInformation() : WifiInfo {
return this.currentWifi;
}
}
Thanks.