在Ionic 2中获取连接到WiFi点设备的Mac地址

汽车制造商

我想知道如何在ionic 2中获取设备连接的wifi网络点的mac地址。

我知道有一个类似的答案在这里,但它是离子1。

卡洛斯·古兹曼

好吧,为了获得该信息,您将需要为离子使用“非本地”插件。我想这一个然后在我的app.component.ts中,我在组件本身之前声明了一个新变量。

declare var WifiInfo

然后在平台准备好后,在我的应用程序构造函数中像这样使用它。

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));
    });

在控制台中,您将看到wifi info mac等。在此处输入图片说明

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章