如何在Phonegap应用程序中获取WiFi网络信息(SSID)? [英] How can I get WiFi Network information (SSID) in a Phonegap app?
问题描述
我在做一个Phonegap应用程序。我的要求是根据用户是使用家庭网络还是公共网络,向用户显示不同的视图。有任何插件或任何其他方式,可以帮助获得连接的网络信息。 (网络SSID)。
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).
感谢。
推荐答案
适用于 Android和iOS 的插件:
cordova plugin add com.pylonproducts.wifiwizard
如果您要获取所连接的网络的当前SSID:
If you want to get the current SSID of the network you are connected to:
function ssidHandler(s) {
alert("Current SSID"+s);
}
function fail(e) {
alert("Failed"+e);
}
function getCurrentSSID() {
WifiWizard.getCurrentSSID(ssidHandler, fail);
}
如果您要获取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);
}
要测试:
<button onclick="getCurrentSSID()">Get Current SSID</button>
<button onclick="getWifiList()">Get configured SSID list</button>
<button onclick="getScanResult()">Get Scan result</button>
请从我提供的链接的函数列表中查看你确实需要的工作如果您遇到问题,请回复。
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.
这篇关于如何在Phonegap应用程序中获取WiFi网络信息(SSID)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!