Ich habe versucht, folgende this Leitfaden Cordova Docs, aber es scheint nicht zu funktionieren.Überprüfen Sie die Internetverbindung in iOS App mit Cordova Phonegap 3.3.0 funktioniert nicht
Hier ist mein Code:
I <plugin name="NetworkStatus" value="CDVConnection" />
-config.xml
hinzugefügt haben.
und dieses Skript zu meinem index.html
:
<script type="text/javascript">
document.addEventListener("deviceready", onDeviceReady, false);
// device APIs are available
//
function onDeviceReady() {
alert("1"); // runs this alert
checkConnection();
}
function checkConnection() {
var networkState = Connection.CELL;
alert("2"); // doesn't run this
var states = {};
states[Connection.UNKNOWN] = 'Unknown connection';
states[Connection.ETHERNET] = 'Ethernet connection';
states[Connection.WIFI] = 'WiFi connection';
states[Connection.CELL_2G] = 'Cell 2G connection';
states[Connection.CELL_3G] = 'Cell 3G connection';
states[Connection.CELL_4G] = 'Cell 4G connection';
states[Connection.CELL] = 'Cell generic connection';
states[Connection.NONE] = 'No network connection';
alert('Connection type: ' + states[networkState]);
}
</script>
var networkState = Connection.CELL;
scheint das Problem zu verursachen, da es nicht die folgende Warnung läuft, ich habe auch versucht, navigator.connection.type
aber das Gleiche passiert.
Wenn ich die App in Chrome die Konsole ausführen gibt die folgende Fehlermeldung:
Uncaught ReferenceError: Connection is not defined
Jeder weiß, wie dieses Problem zu lösen?
Prost
Haben Sie 'Cordova.js' in Ihrer' index.html' Datei –
Ja, ich eingeschlossen haben '' – smj2393