Using cordova plugin (WifiWizard) with Ionic app


I have to get a list of wifi networks and their signal power. I found WifiWizard cordova plugin and tried to use it in my app but it does not work. I’ve also followed this topic but didn’t find solution.

What I’ve tried so far:

  • declaring WifiWizard as let: declare let WifiWizard: any;
  • changing wifiWizard in config.xml and using different values
  • calling window.WifiWizard as it defined in plugins.xml: <clobbers target="window.WifiWizard"/>
  • added WifiWizard.js to the www folder

Do you have any idea why I can’t call method from this class on WifiWizard object? How to make it work? Maybe there is another way to get wifi signal strength?


What exactly is the problem???

I’ve JUST now set up a repo with it running on my android device…

Check out my github and the screengrabs


1 Like

Apologies if you just had a look at the repo - forgot to check the code in.

It’s all there now.

I will take a look at it later but could you tell me how did you install the plugin (what terminal command did you use?)

npm install --save

Straight to source.

Actually thinking about it I might’ve typed in

cordova plugin add  --save

Sorry I mix em up when I’m tired. Notice the lack of ‘ionic’ at the beginning on that statement…

1 Like

Please mark as ‘like’ or ‘solution’ where appropriate. Basic ‘thank you’ courtesy

Thanks for your help! One more thing that is a little bit annoying - why there is no suggesting when I’m typing the WifiWizard. and first letters of the function or object’s property? I’m using VS Code.

You won’t have any intellisense. The plugin itself is not written in typescript and I’m not using any typescript definition.

I referred to the documentation and used the debugger to know what functions I needed.

The best approach (and only approach to consider) is to have a provider with all the required functions being called properly and use said provider instead of direct. If you want to give yourself a little extra pat on on the back have the provider return promises instead of callbacks.

Think of the way Ionic Native providers work (e.g. camera, file).

Is there anything I can make use of to get the signal strengths in wifi wizard?

you can get RSSI which is Received Signal Strength Indicator

1 Like

What do you mean exactly? provider instead of direct

The Provider part was a recommendation. Instead of using the library directly - it’s always best to wrap the functionality required into your own provider (e.g. ionic g provider WifiSomething) and use that instead.

I would recommend this approach always - a couple of benefits…

  • Much easier for testing as you can create mock versions of your provider for testing in a browser…

  • You abstract all the complexity of the library to just what you need for ease of use

  • Swapping the dependency for something later on doesn’t mean changing your code in anywhere other than one file