Okay I solved it by replacing function
with an arrow function (help from here: [Ionic: Uncaught (in promise): TypeError: Cannot read property of null] (Ionic: Uncaught (in promise): TypeError: Cannot read property of null))
So my startScan() function looks like this now:
startScan() {
if (typeof WifiWizard !== 'undefined') {
console.log("WifiWizard loaded: ");
console.log(WifiWizard);
} else {
console.warn('WifiWizard not loaded.');
}
let successNetwork = (e: any) => {
WifiWizard.getScanResults(listHandler, failNetwork);
}
let failNetwork = (e: any) => {
console.log("" + e);
}
let listHandler = (a: any) => {
this.networks = [];
for (let x in a) {
console.log(a[x].SSID + ", " + a[x].BSSID + ", " + a[x].level);
this.networks.push({
ssid: a[x].SSID,
bssid: a[x].BSSID,
level: a[x].level});
}
}
WifiWizard.startScan(successNetwork, failNetwork);
}
To get the plugin working just add it via CLI:
cordova plugin add https://github.com/hoerresb/WifiWizard
and then declare it in the ts file where you want to use it (https://github.com/hoerresb/WifiWizard/issues/94):
declare let WifiWizard: any;
That’s all, package.json and config.xml don’t have any entries linked to the plugin.
Greetings