2016-07-02 21 views
1

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

的index.html

<!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> 

app.js

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

而且在功能connectSuccess window.open过我有问题,window.open不在我的应用程序中工作,如果我从应用程序中退出,我可以访问Google。

config.xml中

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<widget id="com.ionicframework.wifiexpandables353717" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> 
    <name>WifiExpandables</name> 
    <description> 
     An Ionic Framework and Cordova project. 
    </description> 
    <author email="[email protected]" href="http://example.com.com/"> 
     Your Name Here 
    </author> 
    <content src="index.html"/> 
    <access origin="*"/> 
    <preference name="webviewbounce" value="false"/> 
    <preference name="UIWebViewBounce" value="false"/> 
    <preference name="DisallowOverscroll" value="true"/> 
    <preference name="SplashScreenDelay" value="2000"/> 
    <preference name="FadeSplashScreenDuration" value="2000"/> 
    <preference name="android-minSdkVersion" value="16"/> 
    <preference name="BackupWebStorage" value="none"/> 
    <preference name="SplashScreen" value="screen"/> 
    <feature name="StatusBar"> 
    <param name="ios-package" value="CDVStatusBar" onload="true"/> 
    </feature> 
    <platform name="android"> 
    <icon src="resources/android/icon/drawable-ldpi-icon.png" density="ldpi"/> 
    <icon src="resources/android/icon/drawable-mdpi-icon.png" density="mdpi"/> 
    <icon src="resources/android/icon/drawable-hdpi-icon.png" density="hdpi"/> 
    <icon src="resources/android/icon/drawable-xhdpi-icon.png" density="xhdpi"/> 
    <icon src="resources/android/icon/drawable-xxhdpi-icon.png" density="xxhdpi"/> 
    <icon src="resources/android/icon/drawable-xxxhdpi-icon.png" density="xxxhdpi"/> 
    <splash src="resources/android/splash/drawable-land-ldpi-screen.png" density="land-ldpi"/> 
    <splash src="resources/android/splash/drawable-land-mdpi-screen.png" density="land-mdpi"/> 
    <splash src="resources/android/splash/drawable-land-hdpi-screen.png" density="land-hdpi"/> 
    <splash src="resources/android/splash/drawable-land-xhdpi-screen.png" density="land-xhdpi"/> 
    <splash src="resources/android/splash/drawable-land-xxhdpi-screen.png" density="land-xxhdpi"/> 
    <splash src="resources/android/splash/drawable-land-xxxhdpi-screen.png" density="land-xxxhdpi"/> 
    <splash src="resources/android/splash/drawable-port-ldpi-screen.png" density="port-ldpi"/> 
    <splash src="resources/android/splash/drawable-port-mdpi-screen.png" density="port-mdpi"/> 
    <splash src="resources/android/splash/drawable-port-hdpi-screen.png" density="port-hdpi"/> 
    <splash src="resources/android/splash/drawable-port-xhdpi-screen.png" density="port-xhdpi"/> 
    <splash src="resources/android/splash/drawable-port-xxhdpi-screen.png" density="port-xxhdpi"/> 
    <splash src="resources/android/splash/drawable-port-xxxhdpi-screen.png" density="port-xxxhdpi"/> 
    </platform> 
</widget> 
+0

在config.xml中添加以下行并尝试一次。 <允许意图HREF = “市场:*”/> <平台名称= “IOS”> <允许意图HREF = “ITMS:*”/> <允许意图HREF =“ITMS的应用程式:*“/> – Gandhi

+0

它的工作。谢谢 – learner

+0

发表了答案。如果它有用,请接受答案 – Gandhi

回答

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>