-
-
Save CesarBalzer/80eaf1f2ded7b8f2cd097a6cc7cbab51 to your computer and use it in GitHub Desktop.
Cordova Exit App Confirm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener("deviceready", deviceisready, false); | |
function deviceisready(){ | |
alert("Device Ready is called"); | |
document.addEventListener("backbutton", function(e){ | |
if ( $('.ui-page-active').attr('id') == 'mainpage') { | |
//window.location = "#exitDialog"; | |
exitAppPopup(); | |
}else{ | |
history.back(); | |
}; | |
}); | |
}; | |
function exitAppPopup() { | |
navigator.notification.confirm( | |
"Do you really want to close this app?", | |
function(buttonIndex){ | |
ConfirmExit(buttonIndex); | |
}, | |
"Confirmation", | |
"Yes,No" | |
); | |
alert("Outside Notification"); | |
//return false; | |
}; | |
function ConfirmExit(stat){ | |
alert("Inside ConfirmExit"); | |
if(stat == "1"){ | |
navigator.app.exitApp(); | |
}else{ | |
return; | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment