且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2023-02-03 09:34:00

适用于 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.