I haven't been able to find information about network restrictions and Cordova. My question is How can I prevent or restrict the use of mobile (3G/4G) broadband in a Apache Cordova 5 App?
You could use the following plugin. To check the connection type and act on that connection type. For example:
function checkConnection() {
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';
if(!states[Connection.WIFI] || !states[Connection.ETHERNET]) {
alert('Your current connection type: ' + states[networkState] + ' is not supported in this app!');
// Execute anything you want
return;
}
}
checkConnection();