Skip to content

Instantly share code, notes, and snippets.

@PRINCEHR
Forked from fer-ri/app.js
Created April 30, 2017 06:20
Show Gist options
  • Save PRINCEHR/efe2dbe9f3b575b2ca9e899eaa737e3c to your computer and use it in GitHub Desktop.
Save PRINCEHR/efe2dbe9f3b575b2ca9e899eaa737e3c to your computer and use it in GitHub Desktop.
Cordova Exit App Confirm
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;
};
};
@PRINCEHR
Copy link
Author

Thank You

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment