Apache Cordova 宽带
Apache Cordova broadband
我没能找到有关网络限制和 Cordova 的信息。
我的问题是
如何防止或限制在 Apache Cordova 5 应用程序中使用移动 (3G/4G) 宽带?
您可以使用以下 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();
我没能找到有关网络限制和 Cordova 的信息。 我的问题是 如何防止或限制在 Apache Cordova 5 应用程序中使用移动 (3G/4G) 宽带?
您可以使用以下 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();