I have an application built using cordova but I don't know how to add exit/stop function to exit the application.After looking around in google and other sites I got clue to use navigator.app.exitApp()
but it didn't work for me. How can I solve this?
here is my code:
function onDeviceReady() {
var network = navigator.connection.type;
if (network === 'none') {
$cordovaDialogs.confirm('Attention' + '\n' + 'You have no internet connection', '', ['Review Settings', 'Exit'])
.then(function(buttonIndex) {
// no button = 0, 'OK' = 1, 'Cancel' = 2
var btnIndex = buttonIndex;
if (btnIndex == 1) {
$state.go('register');
} else {
navigator.device.exitApp();
}
});