loading...

Answer: Checking internet connection in PhoneGap app

serverbroad profile image Server Broad ・1 min read

try this one.

install this cordova plugin here.

https://github.com/apache/cordova-plugin-network-information

and add this code into js file

document.addEventListener("deviceready", onDeviceReady, false);
// device APIs are available
//

function onDeviceReady() {
    isOnline();
}

function isOnline() {
    var networkState = navigator.connection.type;
    var states = {};
    states[Connection.UNKNOWN] = 'Unknown connection';
    states[Connection.ETHERNET] = 'Ethernet connection';
    states[Connection.WIFI]

Discussion

markdown guide