热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何在Phonegap应用程序中获取WiFi网络信息(SSID)?-HowcanIgetWiFiNetworkinformation(SSID)inaPhonegapapp?

IammakingaPhonegapapp.Myrequirementistoshowdifferentviewstousersdependingonwhether

I am making a Phonegap app. My requirement is to show different views to users depending on whether they are using a home network or a public network. Is there any plugin or any other way that can help to get the connected network information. (Network SSID).

我正在制作一个Phonegap应用程序。我的要求是根据用户是使用家庭网络还是公共网络向用户显示不同的视图。是否有任何插件或任何其他方式可以帮助获取连接的网络信息。 (网络SSID)。

Thanks.

谢谢。

2 个解决方案

#1


16  

There is this plugin for Android and iOS :

这个插件适用于Android和iOS:

cordova plugin add wifiwizard

If you want to get the current SSID of the network you are connected to:

如果要获取所连接网络的当前SSID:

function ssidHandler(s) {
    alert("Current SSID"+s);
}

function fail(e) {
    alert("Failed"+e);
}

function getCurrentSSID() {
    WifiWizard.getCurrentSSID(ssidHandler, fail);
}

If you want to get the list of SSID you have configured before :

如果您想获取之前配置的SSID列表:

function listHandler(a) {
    alert(a);
}

function getWifiList() {
   WifiWizard.listNetworks(listHandler, fail);
}

If you want to return a complete scan result :

如果要返回完整的扫描结果:

function listHandler2(a) {
    alert(JSON.stringify(a));
}

function getScanResult() {
    WifiWizard.getScanResults(listHandler2, fail);
 }

To test:

去测试:

 
 
 

Please see what you exactly need to get work from the list of the functions that the link I provided is offering and if you are encountering issues, reply.

请从我提供的链接提供的功能列表中查看您需要从中获取的工作,如果遇到问题,请回复。

#2


3  

While WifiWizard is great, it seems that it's no longer being maintained on GitHub.

虽然WifiWizard很棒,但它似乎不再在GitHub上维护了。

As a replacement, you can use WifiWizard2 (link) which is under active development, as supports the same methods:

作为替代,您可以使用正在积极开发的WifiWizard2(链接),因为支持相同的方法:

cordova plugin install https://github.com/tripflex/WifiWizard2.git

cordova插件安装https://github.com/tripflex/WifiWizard2.git

WifiWizard2.getConnectedSSID(success, fail)

WifiWizard2.getConnectedBSSID(success, fail)

WifiWizard2.scan([options], success, fail)

WifiWizard2 also supports both Android and iOS.

WifiWizard2还支持Android和iOS。


However, if like me you also need to use the device's Hotspot or Wifi Tetheting on cordova, I recommend the cordova-hotspot-plugin instead.

但是,如果像我这样你还需要在cordova上使用设备的热点或Wifi Tetheting,我推荐使用cordova-hotspot-plugin。

The project is unfortunately discontinued, but for older Android API levels, still seems to work.

不幸的是,该项目已停止使用,但对于较旧的Android API级别,似乎仍然有效。

This plugin supports a myriad of methods, full list available here.

这个插件支持无数的方法,这里有完整列表。


推荐阅读
author-avatar
mobiledu2502908023
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有