Created
March 15, 2014 10:54
-
-
Save fer-ri/9565108 to your computer and use it in GitHub Desktop.
Cordova Exit App Confirm
This file contains 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