Solved here @munsterlander and guys!
If anyone needs !!!
I’ve made a modification to turn on the Network connection , instead of exit the app.
Plugins
cordova plugin network information https://github.com/apache/cordova-plugin-network-information
cordova device https://cordova.apache.org/docs/en/3.0.0/cordova/device/device.html
Cordova-open-native-settings https://github.com/selahssea/Cordova-open-native-settings
On <head> section
function checkConnection() {
// Wait for device API libraries to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// device APIs are available
//
function onDeviceReady() {
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[networkState]) == states[Connection.NONE]) {
if (confirm('Please check your Internet connection. Do you want to acess your settings?')) {
if (typeof cordova.plugins.settings.openSetting != undefined)
cordova.plugins.settings.openSetting("wifi", function () { console.log("acessing now ... please wait") }, function () { console.log("failed to open wifi settings") });
} else {
navigator.app.exitApp();
}
// end even when you turn on the network
navigator.app.exitApp();
}
}
checkConnection();