问题
I have developed the wifi application using wifiwizard and cordova for android devices and it works fine. I can choose the network and I can put the password and I can validate it and connect into it. But the problem is my company got some extra validations like identity number, employee type, and some other details. So how am I suppose to do these stuffs or how to add these for particular networks. I have uploaded my entire wifi application which works exactly I expected. Please have a look and help me to do it still better.
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);
}
And too I'm having problem with window.open in the function connectSuccess, the window.open is not working inside my application and if I come out of my application I can reach 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="you@example.com" 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>
回答1:
Add the following lines in config.xml. It should work fine.
<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>
来源:https://stackoverflow.com/questions/38158255/each-wifi-network-validation-except-password-cordova-wifi