每个wifi网络验证除了密码cordova wifi

时间:2016-07-02 08:46:41

标签: wifi cordova-plugins wificonfiguration

我使用wifiwizard和cordova为Android设备开发了wifi应用程序,它工作正常。我可以选择网络,我可以输入密码,我可以验证它并连接到它。但问题是我的公司得到了一些额外的验证,如身份证号码,员工类型和其他一些细节。那么我怎么想做这些东西或如何为特定的网络添加这些东西。我上传了我的整个wifi应用程序,它完全符合我的预期。请看看并帮助我做得更好。

的index.html

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="result"></div>

app.js

<!DOCTYPE html>
    <head>
        <meta name="format-detection" content="telephone=no">
        <meta name="msapplication-tap-highlight" content="no">
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
        <link rel="stylesheet" type="text/css" href="css/style.css">
        <title>Wifi Wizard</title>
    </head>
    <body>
      <div class = "content">   
                <table id = "displayNetworks" class = "table-responsive">

                </table>
      </div>
        <script type="text/javascript" src="js/jquery-1.12.4.js"></script> 
        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="js/app.js"></script>
    </body>
</html>

我在函数connectSuccess中遇到window.open问题,window.open在我的应用程序中无效,如果我从我的应用程序中退出,我就可以访问Google。

config.xml中

var unique_array = [];

$(document).ready(function(){
    if(navigator.userAgent.match(/(iPhone|iPad|iPod|Android|BlackBerry)/)){
        document.addEventListener("deviceready", onDeviceReady, false);
    }else{
        onDeviceReady();
    }
});

function onDeviceReady(){
    alert("I'm into the browser for debug");
    window.setTimeout(function(){
        WifiWizard.setWifiEnabled(true, win_enable, fail_enable);
    }, 200);
}

function win_enable(){
    alert("Wifi Enabled successfully");
}

function fail_enable(e){
    alert(e.message);
}

window.setTimeout(function(){ alert("I'm in here");
        WifiWizard.startScan(success_scan, fail_scan);
}, 1000);


function success_scan(){ alert("Trying to connect scan function");
    window.setTimeout(function(){
        getScanResult();
    }, 2000);
}

function fail_scan(e){
    alert(e.message);
}

function getScanResult(){alert("Im here too getting the scan result");
    WifiWizard.getScanResults(listHandler, fail_network);
}

function listHandler(a){
    alert(JSON.stringify(a));
    var network_array = [];
    for(var i = 0; i < a.length; i++){
        network_array.push(a[i].SSID);
    }
    unique_array = network_array.filter(function(elem, pos){
        return network_array.indexOf(elem) == pos;
    });
    alert(network_array);
    var content = "<table>"
     for(var j = 0; j < network_array.length; j++){
          content += '<tr class="dynamicTable"><td><a href="javascript:void(0);" onclick="clickWifi(\'' + network_array[j] + '\');">' + network_array[j] + '</a></td></tr>';
     }
     content += "</table>"
     document.getElementById('displayNetworks').innerHTML = content;
}

function fail_network(e){
    alert(e.message);
}

function clickWifi(netssid){ alert("Hello Im inside click function");
    var id = netssid;
    alert(id);
    var promptWindow = prompt("Please enter the password for the network: " + id);
    alert(promptWindow);
    var connectWifi = WifiWizard.formatWPAConfig(id, promptWindow);
        WifiWizard.addNetwork(connectWifi, function(){
            WifiWizard.connectNetwork(id, connectSuccess, connectFailed);
        });
}

function connectSuccess(e){
    alert("Connected Successfully");
    window.open("http://www.google.com", "_self");
}

function connectFailed(e){
    alert(e.message);
}

1 个答案:

答案 0 :(得分:1)

在config.xml中添加以下行。它应该工作正常。

<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
   <allow-intent href="market:*" />
</platform>
<platform name="ios">
   <allow-intent href="itms:*" />
   <allow-intent href="itms-apps:*" />
</platform>