Joe Bohen
Posts: 0
Joined: Wed Nov 28, 2012 11:28 am

Connection Type Undefined

Hi,

I am using the sample function provided by Cordova to test the connection. When I invoke the function I get 'Undefined' returned I am testing on Android 2.2.1 what is the issue here?

Cordova sample code:

function checkConnection() {
var networkState = navigator.connection.type;

Code: Select all

 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.NONE]     = 'No network connection'; 

 alert('Connection type: ' + states[networkState]); 

}

Essay Writing Service
Posts: 0
Joined: Tue Nov 06, 2012 10:39 pm

Connection Type Undefined

navigator.network.connection.type is correct.

Joe Bohen
Posts: 0
Joined: Wed Nov 28, 2012 11:28 am

Connection Type Undefined

Hi Veripuu,

Thanks for the assistance that has don the trick.

regards,
Joe

Winetou
Posts: 0
Joined: Tue Feb 19, 2013 2:26 pm

Connection Type Undefined

Hi Veripuu,
under ios 5 and cordova 2.3.0 is the connection.type undefined!

regards,
Wintou

Return to “Issues”