Skip to content

Instantly share code, notes, and snippets.

@pineoc
Created January 12, 2016 00:16
Show Gist options
  • Save pineoc/2a319bb2a6c3cb20e03f to your computer and use it in GitHub Desktop.
Save pineoc/2a319bb2a6c3cb20e03f to your computer and use it in GitHub Desktop.
document.addEventListener("deviceready", checkConnection, false);
function checkConnection() {
function check(){
var networkState = navigator.connection.type;
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]);
}
check();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment