Monaca Onsen UI Discord Chat Github Repo

Device Back Button can't close the notification

  • I’m trying to make a noitification before closing the application using device back button
    When I tap the device back button, the notification is appear
    But when I tap it again instead of closing the notification, another notification appears again

    Here’s my code

    ons.ready(function () {
          ons.setDefaultDeviceBackButtonListener(function (event) {
            ons.notification.confirm('Do you want to close the app?') // Ask for confirmation
            .then(function(index) {
              if (index === 1) { // OK button
      ; // Close the app

    Is there another way to fix it?
    Thank you