plugin GitHub Link : https://github.com/apache/cordova-plugin-network-information
- installation
$cordova plugin add cordova-plugin-network-information
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} |
댓글 없음:
댓글 쓰기