Ionic 3 get ssid

Someone has a sample code to get wifi ssid where device is connected ?

1 Like

I see only connection type here… :frowning:

Hey,

I think this one is perfect for you

ionic cordova plugin add wifiwizard
Github WifiWizard

Exemple of code

import { Component, OnInit } from '@angular/core';

declare var WifiWizard: any;

@Component({
    selector: 'app-home',
    templateUrl: 'home.page.html',
    styleUrls: ['home.page.scss'],
})
export class HomePage implements OnInit {
    constructor() {}

    ngOnInit() {

        WifiWizard.isWifiEnabled(
            (win: any) => {
                console.log('WIFI enabled', win);

                WifiWizard.getCurrentSSID(
                    (getCurrentSSID: any) => {
                        console.log('WIFI SSID', getCurrentSSID);
                    },
                    (fail: any) => {
                        console.error('WIFI SSID', fail);
                    }
                );

            },
            (fail: any) => {
                console.error('WIFI disabled', fail);
            }
        );


    }
}

Oh many thanks ? can i also use the newer https://www.npmjs.com/package/wifiwizard2 ?

Probably Yes. I don’t tried it

I’ve tried both WifiWizard & WifiWizard2 but does’nt works with this error:
TypeError: Cannot read property ‘isWifiEnabled’ of undefined

But this is not a standard plugin that i’ve to import?

This code works fine for me.
You dont forgot this line above @Component?
declare var WifiWizard: any;

This is my code and error…

declare var WifiWizard2: any;

@IonicPage()
@Component({
  selector: 'page-welcome',
  templateUrl: 'welcome.html',
})
export class WelcomePage {

  constructor(
    public navCtrl: NavController,
    public navParams: NavParams,
    public store: Store,
    private network: Network
  ) {

  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad WelcomePage');
    console.log(JSON.stringify(WifiWizard2.getConnectedSSID()));
    let net = this.network.type;
    console.log(JSON.stringify(net));
    debugger;

You must run it in device. ex: ionic cordova run android
Not in browser (in browser cordova not running)

Sure, i’m running also on android device but app crash…
Do you have a sample prj to share? :slight_smile:

I read somewhere that wifiwizard & wifiwizard2 are working only in production mode, is it true ?
I’ve done many tests but no one working in dev mode…

also… what’s the difference to install with npm i wifiwizard OR cordova plugin add com.pylonproducts.wifiwizard?which one is better to use?
Thanks

get extra wifi info: like SSID, IP, Getway, Mac address etc.
try this plugin: https://github.com/Riyaz0001/cordova-plugin-wifi-info

Ionic 4 example here: https://github.com/Riyaz0001/cordova-plugin-wifi-info-ionic4-demo

Thanks, can use it also for Ionic 3 prj ?

1 Like

yes, I am already using this plugin in ionic 3 project.

I’m running your demo on Android device but, look…

Tested on Ios iphone, prj does’nt start… :frowning:
Running ios with cmq: ionic cordova run ios -l -c -s --debug --buildFlag="-UseModernBuildSystem=0" app start with some error but pressing buttons crash…

Some help?

This plugin does’nt works for Android >= 8.1 ! :face_with_raised_eyebrow:

sorry, its work for Android API 28 - 9.0
just use this commend:

ionic cordova platform rm android
ionic cordova platform add android@8.0.0
ionic cordova run android

Note: just update your cordova-android@8.0.0 library.

Regards thanks.

1 Like

I was trying to use the plugins Hotspot, and wifiwizard2 in V4, I had to back to V3, so again did the test in browser and not work, then I run build and only in device its work I did to show the list the networks using Hotspot

even using this comand ionic serve --lab --devapp cordova run browser and noting, only in device and in V3 Ionic