Reputation: 325
I was wondering how I could get the mac address of the wifi network point the device is connected to in ionic 2.
I know there is a similar answer here, but it is for ionic 1.
Upvotes: 2
Views: 2354
Reputation: 2232
Okay so in order to get that info you will need to use a 'non native' plugin for ionic. I tried this one. Then in my app.component.ts I declared a new variable before the component itself.
declare var WifiInfo
then in my app constructor after the platform ready I use it like this.
this.platform.ready()
.then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things
// you might need.
this.statusBar.styleDefault();
this.splashScreen.hide();
// console log an object with wifi info
WifiInfo.getWifiInfo(wifiInfo => console.log(wifiInfo),
wifiError => console.log(wifiError));
});
In the console you will see the wifi info mac, etc.
Upvotes: 4