I am working with Cordova based vue.js related app with Monaca and onsen.ui. I need to work on the Android Back button so that it shows me a confirmation message whenever a user presses the back button of the phone. it must show two option 'Yes' and 'No'. If user presses 'yes' then the user will leave the app and otherwise will stay in the app. As I am new with Vue.js, Plese help me to find a solution for implementing it in vue.js. I have tried other solution available in StackOverflow, but nothing seems to be working. I will be grateful for your help.
mounted(){
document.addEventListener('backbutton', this.onBackKeyDown, false);
},
methods{
onBackKeyDown: function (e) {
e.preventDefault();
alert('Back Button is Pressed!');
navigator.notification.confirm("Are you sure you want to exit ?",this.onConfirm(), "Confirmation", "Yes,No");
// Prompt the user with the choice
},
onConfirm: function (button) {
if (button === 2) {
return;
} else {
navigator.app.exitApp();
}
},
}