我还没有找到有关网络限制和Cordova的信息。 我的问题是 如何在Apache Cordova 5 App中阻止或限制使用移动(3G / 4G)宽带?
答案 0 :(得分:1)
您可以使用以下plugin。检查连接类型并对该连接类型执行操作。例如:
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();